I am trying to perform 2 operations in one findOneAndUpdate()
:
- Update date in one field
lastUpdatedTimestamp
, set it to current date (this one works fine in my statement), Update date in other field
expiryTimestamp
, by adding 1 day to$currentDate
(I couldn't find a way to achieve it so I'm trying to$add
1 day to the the value read from the above fieldlastUpdatedTimestamp
) - (I can't make this one work).findOneAndUpdate( {"_id":123}, { $currentDate: {"lastUpdatedTimestamp":true}, $set: {"expiryTimestamp": {$add: ["$lastUpdatedTimestamp", 24*60*60000]}}} )
Here's the error I'm receiving:
{ "ok" : 0.0, "errmsg" : "The dollar ($) prefixed field '$add' in 'expiryTimestamp.$add' is not valid for storage.", "code" : 52 }
Is it even possible? I'd appreciate your help.