[DOCS-11156] Comment on: "manual/reference/method/db.collection.update" Created: 26/Dec/17  Updated: 30/Oct/23  Resolved: 09/Apr/18

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

Type: Bug Priority: Minor - P4
Reporter: Docs Collector User (Inactive) Assignee: Stennie Steneker (Inactive)
Resolution: Works as Designed Votes: 0
Labels: mts
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongodb with nodejs

Location: https://docs.mongodb.com/manual/reference/method/db.collection.update/index.html
Referrer: https://docs.mongodb.com/manual/reference/operator/aggregation/project/?searchProperty=current&query=update%20filter
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/63.0.3239.84 Chrome/63.0.3239.84 Safari/537.36
Screen Resolution: 1366 x 768


Participants:
Days since reply: 5 years, 44 weeks, 2 days ago
Story Points: 0.25

 Description   

db.students2.update(
   { },
   { $set: { "grades.$[elem].mean" : 100 } },
   {
     multi: true,
     arrayFilters: [ { "elem.grade": { $gte: 85 } } ]
   }
)

wrong query not run proper give error



 Comments   
Comment by Stennie Steneker (Inactive) [ 09/Apr/18 ]

The quoted example code is from the MongoDB 3.6 server documentation and uses the new filtered positional operator ($[elem]) and arrayFilters features.

If you are using an older version of MongoDB server that does not support this syntax you will get an error similar to:

WriteResult({
  "writeError": {
    "code": 9,
    "errmsg": "Unrecognized field in update operation: arrayFilters"
  }
})

Note that the DOCS project is for reporting documentation errata or suggestions. For appropriate channels for MongoDB-related support discussion please refer to Technical Support options in the MongoDB documentation.

Regards,
Stennie

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