Error trying to updateOne in mongo - $set syntax
See original GitHub issueRepro 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:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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!
How can I enclose array values in double quotes.
@StephenWeatherford