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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.