Reputation: 767
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
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