query in mongo Shell gives SyntaxError: missing : after property

This error also comes if ":" is missed.

In my case I missed the ":" after $set like the below.

db.myData.updateOne({_id:ObjectId("new_id")},{$set{name:"new_name"}})

I faced the same error mentioned in the title and my changed code that works is

db.myData.updateOne({_id:ObjectId("new_id")},{$set:{name:"new_name"}})

Hope this helps people who did my mistake.


If your query includes inner documents, then use quotes for them. Also, use quotes for querying String values

db.movieDetails.find(
  { year: 2013, "imdb.rating": "Pg-13", "award.wins": 0 },
  { title: 1, _id: 0 }
).pretty();