-1

I wanted to insert a new field to all the documents in my collection named 'students' where the age is >19..but I am getting an error.

I run the following command:-

my_db> db.students.updateMany({age:{$gt:19},{$set:{'marks':9}}})
 

and the error shown is:-

SyntaxError: Unexpected token (1:37) > 1 | db.students.updateMany({age:{$gt:19},{$set:{'marks':9}}})

m_anand
  • 1
  • 1
  • Make sure to close the brackets correctly. Refer the documentation. https://www.mongodb.com/docs/manual/reference/method/db.collection.updateMany/ – Noel Dec 27 '22 at 11:44
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 27 '22 at 17:55

1 Answers1

1

You didn't close the curly brackets correctly, change this to:

db.students.updateMany({age:{$gt:19}},{$set:{'marks':9}});
fullstack
  • 754
  • 3
  • 20