I have a model structured as follows:
const List = new Schema({
name: { type: String, unique: true, required: true, dropDups: true },
cards: [{ type: Schema.Types.ObjectId, ref: 'Card' }],
orderItems: [{ value: Number, card: { type: Schema.Types.ObjectId, ref: 'Card' } }]
});
My document instance of that model is represented like this:
{ _id: ObjectId: ("1234567890"), cards: [...], OrderItems: [{ card: ObjectId: ("0987654321"), value: 1.1, _id: ObjectId: ("1029384756") }] }
I am attempting to update the value property of the single object in the OrderItem's array within my document. I have tried common methods such as:
doc.OrderItems[0].value = 1.2;
doc.save();
Unfortunately, this approach does not seem to be effective. How can I successfully achieve this?