Details
-
Improvement
-
Resolution: Won't Do
-
Major - P3
-
None
-
None
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.