http://www.mongodb.org/display/DOCS/Scripting+the+shell
paragraph "Differences between scripted and interactive / Printing".
connect to host:
./mongo server.com/mydb
> db.users.find()
to do the same from shell:
./mongo server.com/mydb --quiet --eval "db.users.find().forEach(printjson);" > 1.txt
Attention: for prefix ".forEach(printjson);" without it you will get error like
DBQuery: mydb.users-> undefined
No comments:
Post a Comment