Reputation: 782
At present I'm doing this to update a Collection whenever a webhook is fired indicating changed object data:
Products.update( {id: shopifyID }, { $set: doc });
Products.update( {id: shopifyID }, { $set: { lowestPrice: lowestPriceVariant(doc) }});
However, I'm trying to achieve that with just one update
call. The first is setting the object to whatever object is returned by a webhook, which is why there is no mapping of key/value. Is this possible with mongoDB? So far, any combination I have tried only updates lowestPrice
.
Upvotes: 0
Views: 22
Reputation: 111
How about:
doc.lowestPrice = lowestPriceVariant(doc);
Products.update( {id: shopifyID }, { $set: doc });
Upvotes: 1