question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error trying to updateOne in mongo - $set syntax

See original GitHub issue

Repro steps:

I have data that looks like this

{
  "_id": "5a987da06c23a84554ae0519",
  "name": "Esteban Lothbrok",
  "id": 1,
  "__v": 0,
  "description": "aka Ragnar Sigurdsson"
}

and I try to run this command:

   db.heroes.updateOne(
      { "name" : "Esteban Lothbrok" },
      { $set: { "description" : "aka Ragnar Sigurdsson 2" } }
   );

Action: cosmosDB.executeMongoCommand Error type: Error Error Message: Error near line 5, column 5, text ‘$set’. Please check syntax.

Version: 0.6.0 OS: darwin

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
StephenWeatherfordcommented, May 26, 2018

@LordDraagonLive Thanks for raising this issue. This appears to be the same problem addressed in https://github.com/Microsoft/vscode-cosmosdb/issues/489. Until that’s fixed, you can work around it by putting the squiggly brace on the same line as the ending square bracket:

db.createUser({ “user”: “buddhi”, “pwd”: “123”, “roles”: [“readWrite”, “dbAdmin”]} )

Happy coding!

0reactions
LordDraagonLivecommented, May 24, 2018

image How can I enclose array values in double quotes.

@StephenWeatherford

Read more comments on GitHub >

github_iconTop Results From Across the Web

updateOne on MongoDB not working in Node.js
Use {$set: {"name": req.body.name}} (as Sparw mentioned) to update the the properties you want in the document.
Read more >
db.collection.updateOne() — MongoDB Manual
Syntax. The updateOne() method has the following syntax: ... Do not explicitly set the write concern for the operation if run in a...
Read more >
MongoDB operators are detected as syntax error in `update`
Using next version and MongoDB driver, I'm trying to use $set / $push / $addToSet with repository.update method.
Read more >
Update Single Document using updateOne() in MongoDB
Use the db.<collection>.updateOne() method to update a single document in a collection that matches with the specified filter criteria. It updates the first ......
Read more >
MongoDB updateOne() Method - db.Collection.updateOne ...
The first parameter is the Older value in the form of Documents. · The second parameter must contain a $set keyword to update...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found