SyntaxError: missing : after property id @(shell) when specifying _id

Hello,
I got this error E QUERY [js] SyntaxError: missing : after property id @(shell):1:55 when I insert a new entry specifying the _id field as follows

db.moviesScratch.insertOne({ _id : "tt008472", "title:"Star Trek II: The Wrath of Kahn", year:"1982", imdb:"tt008472"})

MongoDB shell version v4.0.3
MongoDB server version: 3.6.8

Maybe I’m just too tired… any idea?

Regards,
Gabriele

May be should be “title”:“Star…” or title : “Star…”.
Seems you add extra quote symbol before title word.

Thank you Viktor. I’m definitely too tired to code…

When using the command line interface, your keys MUST be surrounded by quotes. Make sure that _id is shown as “_id” and try again.

2 Likes