0

So I want to have a nested schema like this,

const somethingSchema = new Schema({
  something: {
    type: String,
    required: true
  },
  objectCanBeNull: {
    type: new Schema({
      name: {
        type: String,
        required: true
      }
    })
  }
})

Then error E11000 duplicate key error collection appears when I try to insert 2 documents without objectCanBeNull. I found out the problem is with the nulls, so MongoDb takes it as a duplicate and throws that error. What should I do to solve this?

0 Answers0