Neno
Neno

Reputation: 767

getting "missing ; before statement" error when trying to use eval in mongodb shell

enter image description here

I want to try out executing javascript from mongo shell. mongo test --eval "printjson(db.getCollectionNames())"

However, I'm getting the error as you can see on the above screenshot.

Upvotes: 0

Views: 709

Answers (1)

Oleks
Oleks

Reputation: 1633

The "--eval" option is used in Scripted mongo, you should not be already connected to the shell. Use that as in an example below:

mongo YOUR_DB_NAME --eval "printjson(db.getCollectionNames())"

Upvotes: 1

Related Questions