Open dinesh6383 opened 1 year ago
This is a monogo error. In your mongoose schema you maybe defined as username {type string, unique:true}. So when you are storing data in DB, only one null value for username will store. After that if username field has null value duplicate error will throw. Change username field as below
username: { type: String, index: true, unique: true, sparse: true, }
After changing the schema. Drop that specific collection. And try again. No username field will only take multiple null values.
It still doesn't work...
I couldn't be able to register through facebook once after i registered and logout out from google auth. Kindly someone help me to solve this issue!. ///////////////////////////////////////////////////////////////////////////////////////////////////////// MongoServerError: E11000 duplicate key error collection: usersDB.users index: username_1 dup key: { username: null } at E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\operations\insert.js:53:33 at E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\cmap\connection_pool.js:308:25 at E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\sdam\server.js:213:17 at handleOperationResult (E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\sdam\server.js:329:20) at Connection.onMessage (E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\cmap\connection.js:219:9) at MessageStream. (E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\cmap\connection.js:60:60)
at MessageStream.emit (node:events:527:28)
at processIncomingData (E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\cmap\message_stream.js:132:20)
at MessageStream._write (E:\backend-development\Secrets - Starting Code\node_modules\mongodb\lib\cmap\message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:389:12) {
index: 0,
code: 11000,
keyPattern: { username: 1 },
keyValue: { username: null },
[Symbol(errorLabels)]: Set(0) {}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////