[DOCS-10338] findOneAndUpdate (and findAndModify) needs sample code for how to do non-updating upserts Created: 02/Jun/17  Updated: 30/Oct/23

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: William Byrne III Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 1 year, 14 weeks, 2 days ago
Epic Link: DOCSP-1769

 Description   

If you want to use findOneAndUpdate (which is just a wrapper for findAndModify) to:

  • search for a document matching filter conditions {f1:v1, f2:v2, ...}
  • if it is not found, insert one and return it
  • if it is found, return it without updating it

it is not clear in our documentation how to achieve that.

This can be fixed by adding an example at the appropriate places in the docs that explains if both the <query> and <update> parameters to findOneAndUpdate are set to the same set of key:value equality conditions {f1:v1, f2:v2, ...}, then the existing document will not be updated.



 Comments   
Comment by Education Bot [ 31/Oct/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Generated at Thu Feb 08 08:00:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.