I have a model in MongoDB called "order". It has a field called "status" and a field called "last_status". There is a function which has to set a value to field "status".
My question is when I do it like this:
let order = await OrderModel.findOneAndUpdate(
{
_id: ObjectId(orderId),
},
{
$set: {status: ORDER_STATUS.CANCELED, 'cancelInfo.lastStatus': status},
},
Does the 'cancelInfo.lastStatus' field gets previous value of status or gets it's new value.
Thanks for any help.