[SERVER-4900] $ifnotpresent Created: 07/Feb/12  Updated: 07/Mar/14  Resolved: 07/Feb/12

Status: Closed
Project: Core Server
Component/s: Usability, Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Philipp Heinze Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: Operator
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Issue Links:
Duplicate
duplicates SERVER-340 $setOnInsert modifier for upsert Closed
Participants:

 Description   

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.



 Comments   
Comment by Philipp Heinze [ 07/Feb/12 ]

Duplicate, just found SERVER-340 which requests the same.

Generated at Thu Feb 08 03:07:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.