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,
});
This is the data schema, after the first insert, the second one always out put error. The email field is not indexed and the email field of the first one is not null. The second insert is not null either.
E11000 duplicate key error collection: gdaymobile.users index: email_1 dup key: { : null }
via qwang
No comments:
Post a Comment