D
D
DeniSidorenko2020-10-23 07:43:39
Mongoose
DeniSidorenko, 2020-10-23 07:43:39

mongoDB error email_1 dup key: { email: null } but I don't use email?

Good afternoon, made additions of products. 1 product is added perfectly, but the second one gives such an error.
message: "E11000 duplicate key error collection: dbName .products index: email_1 dup key: { email: null }"
I looked it up on Google and it says that the e-mail must be unique or not null as in this case.

But the problem is that these are products, they do not receive a bunch of e-mails.
Here is a diagram

const {Schema, model, Types} = require('mongoose')

const schema = new Schema({
  name: {type: String, required: true},
  price: {type: Number, required: true},
  rating: {type: Number, default: 4.7},
  weight: {type: String, required: true},
})


module.exports = model("Product", schema)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Cheremkhin, 2020-10-23
@Che603000

Delete the Product collection manually.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question