【发布时间】:2016-11-25 13:56:32
【问题描述】:
我不知道如何在标题中准确解释我的问题。很抱歉。
这就是我的意思: 我有用户模型
var userSchema = new Schema({
username: { type: String, required: true },
messages: { type: Number, required: true, default: 0 },
noticed: { type: Date, required: true, default: Date.now },
chatId: { type: Number, required: true }
})
username 和chatId 可能不是唯一的,但应该没有username 和chatId 相同的用户!
这意味着在一个聊天中不能有两个用户具有相同的用户名。但是用户可能在许多不同的聊天中。 我如何在猫鼬中做到这一点?
【问题讨论】:
标签: javascript node.js mongodb mongoose