CodeWithHarry / iNotebook-React

INotebook is a React Application for managing personal notes on the cloud
343 stars 193 forks source link

ERORR :::: E11000 duplicate key error collection: inotebook.users index: email_1 dup key: { email: "@gmail.com" } #25

Closed Chandraprakash-Darji closed 2 years ago

Chandraprakash-Darji commented 2 years ago
/home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/operations/insert.js:51
                return callback(new error_1.MongoServerError(res.writeErrors[0]));
                                ^

MongoServerError: E11000 duplicate key error collection: inotebook.users index: email_1 dup key: { email: "prakashchandra3786@gmail.com" }
    at /home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/operations/insert.js:51:33
    at /home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/cmap/connection_pool.js:273:25
    at handleOperationResult (/home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/sdam/server.js:363:9)
    at MessageStream.messageHandler (/home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/cmap/connection.js:474:9)
    at MessageStream.emit (node:events:520:28)
    at processIncomingData (/home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
    at MessageStream._write (/home/chandraprakash/Desktop/React/i_notebook/backend/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at MessageStream.Writable.write (node:internal/streams/writable:334:10) {
  index: 0,
  code: 11000,
  keyPattern: { email: 1 },
  keyValue: { email: 'prakashchandra3786@gmail.com' }

Hello: I am getting this Error when the in UserSChema email Unique is true.

  email: {
    type: String,
    required: true,
    unique: true,
  }

As i remove the the uquie i can add muktipke duplicate entries.. Any Way to handle

Chandraprakash-Darji commented 2 years ago

Visit Video 47 for these Error

MuscleheadDeveloper commented 2 years ago

how did you solve this, please? I am getting the same error except i have email as null