So I have this Schema which has an array
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
let colorsSchema = new Schema({
value: String
});
let sizesSchema = new Schema({
value: String
});
let tshirtSchema = new Schema({
id: { type: String, unique: true },
name: String,
url: { type: String, unique: true },
colors: [colorsSchema],
sizes: [sizesSchema],
available: Boolean
}, { versionKey: false });
module.exports = mongoose.model('Tshirt', tshirtSchema);
When I insert a new document it gives me an error saying
E11000 duplicate key error index: wwc.tshirts.$sizes.value_1 dup key: { : "L" }
I tried giving the fields unique indexes too but the error still persists.