84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
用户注册有两个属性name和address,怎么设置数据库让这两个属性对应相等而不发生重复。 我的意思就是不希望出现一个address对应多个用户名
谢谢
If I understand correctly, create a unique matching index:
.createIndex( { name: 1, address: 1 }, { unique: true } )
It is recommended to check the official MongoDB manual to improve work efficiency.
Love MongoDB, Have Fun!
var studentSchema = new Schema({ school:String, nickname:String, username:{ type:String, unique:true },..... }
Mine schema is like that, you can try the following and see if it works
schema
name:{ type:String, unique:true }, address:{ type:String, unique:true }
If I understand correctly, create a unique matching index:
.createIndex( { name: 1, address: 1 }, { unique: true } )
It is recommended to check the official MongoDB manual to improve work efficiency.
Love MongoDB, Have Fun!
Mine
schema
is like that, you can try the following and see if it works