[DOCS-9701] Comment on: "primer/update.txt" Created: 27/Dec/16  Updated: 27/Oct/23  Resolved: 28/Dec/16

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

Type: Bug Priority: Trivial - P5
Reporter: Docs Collector User (Inactive) Assignee: Allison Reinheimer Moore
Resolution: Works as Designed Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.com/getting-started/node/update/
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0
Referrer: https://docs.mongodb.com/getting-started/node/query/
Screen Resolution: 1920 x 1080


Participants:
Days since reply: 7 years, 7 weeks ago
Story Points: 0.25

 Description   

var updateRestaurants = function(db, callback) {
   db.collection('restaurants').updateOne(
      { "name" : "Juni" },
      {
        $set: { "cuisine": "American (New)" },
        $currentDate: { "lastModified": true }
      }, function(err, results) {
      console.log(results);
      callback();
   });
};

in this document you use

{ "name" : "Juni" }

to update and in $set method you use

{ "cuisine": "American (New)" }

 Comments   
Comment by Allison Reinheimer Moore [ 28/Dec/16 ]

The {"name": "Juni"} specifies which document to update (the one where name is "Juni", while the $set method specifies what field to update, in this case, to set cuisine to "American (New)".

Here's the method reference for the updateOne syntax for the node.js driver and the MongoDB Shell.

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