I'm making a project with node, mongoose and express.
I have this schema in mongoose
const userSchema = new Schema({
local: {
email: {
type: String,
lowercase: true,
unique: true,
....
},
password: {
type: String
}
},
google: {
googleId: String,
email: String
},
....
};
Because i have two passport strategies (local for the classic email, password and google).
But when i create two accounts with different google accounts. The console shows me this error:
{ MongoError: E11000 duplicate key error collection: xxx.users index: local.email_1 dup key: { : null }
WHAT?? The "Unique" detect duplicated two undefined values?
So. How can i avoid this?
Thank you :)
via nano
No comments:
Post a Comment