const UserSchema = new Schema ({
mobile: {type: String, unique: true, required: [true, 'Mobile Required']},
verified: {type: Boolean, default: false},
password: {type: String, required: [true, 'Password Required']},
salt: {type: String, required: [true, 'Salt Required']},
type: {type: Number, required: [true, 'User Type Required']},
storeId: {type: Schema.Types.ObjectId, ref: 'Store', default: null},
username: {type: String, lowercase: true, unique: true},
userInfo: {
name: String,
email: String,
address: String,
postcode: String,
},
likes: [{type: Schema.Types.ObjectId, ref: 'Post'}],
}, {
timestamps: true,
versionKey: false,
});
这是数据模式,在第一次插入后,第二次总是输出错误。电子邮件字段未编入索引,并且第一个电子邮件字段的电子邮件字段不为空。第二个插入也不为空。
E11000 duplicate key error collection: gdaymobile.users index: email_1 dup key: { : null }