For my documents I need to track modifiers like creation/modification date as well as creator/lastmodifiedBy user. As the creation creator props are not changing it would be great (I think this makes sense at other parts as well) to have an operator for update Operations which only sets a value if it's not already present within the collection. Currently to get this functionality I would need to retrieve the document before I can set the values.
Short example how the operator would look and work like:
{ $ifnotpresent :
{ "creator": curUser }, $set : { "lastmodifier" : curUser}} would only set creator if the document to update doesn't hold that field already, if it's already present nothing is changed.
- duplicates
-
SERVER-340 $setOnInsert modifier for upsert
- Closed