-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Minor - P4
-
None
-
Affects Version/s: 3.4.10, 3.4.15
-
Component/s: JavaScript, Usability, Write Ops
-
None
-
Query
-
ALL
-
https://docs.mongodb.com/manual/reference/operator/update/setOnInsert/
According to the documentation, "If the update operation does not result in an insert,$setOnInsert does nothing."
This statement is not true for all cases. The documentation should be changed to "$setOnInsert does insert values" or equivalent rather than "$setOnIN=nsert does nothing". In the case where javascript function is specified inside $setOnInsert clause, the javascript function is still executed dispite no document insertion.
Reproduction steps is verified on mongodb 3.4.10 and 3.4.15.