Pass parameters to meteor mongo from the shell


#1

How can I pass parameters to meteor mongo as I would do with mongo? for instance with a normal mongo,

$ mongo --eval "db.users.find({}).count()"

works but

$ meteor mongo --eval "db.users.find({}).count()"

fails because meteor mongo only accept a --url parameter


#2

you can use the output of mongo --url and feed it to mongo --eval, no?

> meteor mongo --url
mongodb://127.0.0.1:3001/meteor
> mongo --quiet mongodb://127.0.0.1:3001/meteor --eval 'db.users.find().count()'
0

#3

excellent! that works like a charm


#4

Or, as a one-liner:

mongo --quiet $(meteor mongo --url) --eval 'db.users.find().count()'