a commandline tool to run mongo queries to stdout
npm install -g monget
-c, --conn a mongodb connection string (see http://www.mongodb.org/display/DOCS/Connections) -s, --save save the connection to a .monget file in the current directory [boolean]
monget --conn mongodb://localhost/myDB "db.users.findOne()" > user.json
monget requires a mongodb connection string. From the mongo docs:
If no connection string is passed in the
--conn argument, monget will check for a connection string in a file called
.monget. You can call monget with the
--save flag to save the connection string argument to the .monget file for convenience.
The things you're going to want to do in the mongoshell are run one-liner queries. As such, we make things easier for you:
()if you don't explicitly invoke a method
.find(default mongoshell interactive behavior)
This means you can either write
$ monget "db.MyCollection.findOne()"
(note the quotes necessary in Bash when using parentheses)
$ monget MyCollection.findOne
We're here to make your life easier, because we love you.
Written by Jason Denizac firstname.lastname@example.org
Copyright 2012 Agile Diagnosis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.