this question has answer here:
i don't know how explain question in title. sorry that.
here mean: have user model
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
may not unique, there should no users username
, chatid
both same!
meaning of there can not 2 users same username in 1 chat. user may in many different chats. how do in mongoose?
i think work:
userschema.index({ username : 1, chatid : 1 }, { unique : true });
Comments
Post a Comment