Open being-nitin opened 2 years ago
This can be fixed by adding a username element to your schema.
const userSchema = new mongoose.Schema({
username: String,
name: String,
googleId: String,
message: String,
picture: String,
messages: Array,
});
Then in findOrCreate add
function (accessToken, refreshToken, profile, cb) {
// console.log(profile);
User.findOrCreate(
{
googleId: profile.id,
name: profile.name.givenName,
picture: profile._json.picture,
username: profile.displayName,
},
function (err, user) {
return cb(err, user);
}
);
}
E11000 duplicate key error collection: userDB.users index: username_1 dup key: { username: null }