I have a model that looks like this:
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' } }]
});
And a document base of that model that looks like this:
{ _id: ObjectId: ("1234567890"), cards: [...], OrderItems: [{ card: ObjectId: ("0987654321"), value: 1.1, _id: ObjectId: ("1029384756") }] }
I want to update the value of the only object that's in the OrderItem's array of my document, I tried the most obvious methods like:
doc.OrderItems[0].value = 1.2;
doc.save();
but that's not working, how can I do it?
CodePudding user response:
Turns out that the method I was using was correct, the issue was when I was calling the parameters in my server function trough my endpoint