How should i get the _id of newly inserted/updated value in object array.
Currently i am using ‘“quantity.$._id”: 1‘
but it’s still returning whole document.
.
updatePackage.pricingCreated = await Item.findOneAndUpdate(
{ _id: entry.itemID, 'quantity._id': entry.storageID },
{
$addToSet: { "pricing": [{ "firstAddedDate": today, mrp: entry.mrp, price: entry.price, qty: entry.qty }]} ,
$inc: { 'quantity.$.qty': entry.qty },
},
{ "quantity.$._id": 1, returnDocument: "after"})