error missing after property list

Query mongo shell throws SyntaxError: missing } after property list

When you are trying to insert document in MongoDB collection you might see this SyntaxError: missing } after property list.

Problem Statement

Let  say you are trying to insert the following document in the collection called ‘posts’ using the following mongo shell command.

> db.posts.insert(
... {
... _id: ObjectId('5063114bd386d8fadbd6b009')
... title: 'MongoDB OverView',
... description: 'Overview and Introduction about MongoDB',
... by: 'Sneppets',
... url: 'https://docs.mongodb.com',
... tags: ['#mongodb', '#mongo_tutor', '#tutorials'],
... likes: 20,
... comments: [
... {
... user: 'John',
... message: 'Nice tutorial',
... dateCreated: new Date(2019,1,25,7,45),
... like: 10
... },
... {
... user: 'Paul',
... message: 'Good one',
... dateCreated: new Date(2019,1,25,7,45),
... like: 12
... }
... ]
... }
... )

2019-03-06T12:47:57.083+0530 E QUERY [js] SyntaxError: missing } after property list @(shell):4:0

Solution

From the above output, we see there is a syntax error at line number 4 and column number 0 and it says the property list is not terminated properly. Look at 3rd line.

_id: ObjectId('5063114bd386d8fadbd6b009')

There is no “comma” after this property list item in the document or data object that you are trying to insert, try adding comma to solve “syntax error missing } after property list”. Hope it  helped.

Related Posts

References

Leave a Reply

avatar
  Subscribe  
Notify of