I just want to run a .js script against a particular mongodb database, but can't seem to get the correct syntax.
echo "print(db.address.find().limit(1));" > test.js
mongo test.js
How do I select the database that this will be executed on, I've tried various combinations of use foo
with no success.
> show dbs
admin (empty)
local (empty)
foo 0.203125GB
bar 0.203125GB
I would like to use foo
in this case.