我不知道如何在标题中准确解释我的问题。对不起。
这就是我的意思: 我有用户模型
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
两者都相同的用户!
这意味着在一次聊天中不能有两个用户具有相同的用户名。但是用户可能会进行许多不同的聊天。 我怎么用猫鼬做的?
答案 0 :(得分:0)
我认为这会奏效:
options