[DOCS-560] Syntax change in findAndModify now requires explicit use of query, remove, update Created: 26/Sep/12  Updated: 27/Sep/12  Resolved: 27/Sep/12

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: v1.0
Fix Version/s: None

Type: Improvement Priority: Critical - P2
Reporter: Daniel Pasette (Inactive) Assignee: Ed Costello
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Participants:
Days since reply: 11 years, 20 weeks, 6 days ago

 Description   

2.0.7:

> db.test.findAndModify({"_accountId" : "100000057408993"}, {"$unset": {"gifts.5c06e45d229c4ed5800a26f1b66bde4a":true}});
null

2.2.0:

> db.test.findAndModify({"_accountId" : "100000057408993"}, {"$unset": {"gifts.5c06e45d229c4ed5800a26f1b66bde4a":true}});
Wed Sep 26 19:06:04 uncaught exception: findAndModifyFailed failed: {
  "errmsg": "need remove or update",
  "ok": 0
}

Need to change the command to explicitly use the query and update documents. This was changed with SERVER-1117.

2.2.0:

> db.test.findAndModify( {query:{"_accountId" : "100000057408993"}, update:{"$unset": {"gifts.5c06e45d229c4ed5800a26f1b66bde4a":true}}});



 Comments   
Comment by Daniel Pasette (Inactive) [ 27/Sep/12 ]

As scott noted, this slight change is not worth documenting.

Comment by Scott Hernandez (Inactive) [ 27/Sep/12 ]

Dan, that syntax never worked but might have resulted in no error message. Is that what you mean to doc? I really don't think anything has changed except that we now return the error correctly.

This

db.test.findAndModify({"_accountId" : "100000057408993"}, {"$unset": {"gifts.5c06e45d229c4ed5800a26f1b66bde4a":true}});

turns into this command:

{ findandmodify: "test", _accountId: "100000057408993" }

The change is that the command now validates the options before running the query/returning (if there is no match the old version never seemed to complain that there is no update/etc. because there was nothing to do) The code uses an empty query if nothing is specified, like in the bad syntax case.

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