i have the following schema:
const productSchema = new mongoose.Schema(
{
name: { type: String, required: true, unique: false },
slug: { type: String, required: true, unique: false },
category: { type: String, required: true, unique: false },
image: { type: String, required: true, unique: false },
price: { type: Number, unique: false },
countInStock: { type: Number, required: true, unique: false },
brand: { type: String, required: true, unique: false },
rating: { type: Number, required: true, unique: false },
reviews: { type: Number, required: true, unique: false },
description: { type: String, required: true, unique: false },
},
{
timestamp: true,
}
);
Even though i’ve set the unique: false property everywhere, i always get MongoBulkWriteError: E11000 duplicate key error collection: react-store.Products index: price_1 dup key: { price: 123 }
How does that even happen? There is no restraint on the unique, I don’t want price to be unique and i’ve explicitly said so in the schema.
I’m losing my mind here