https://github.com/robertklep/mongo-cli
Query MongoDB from CLI
https://github.com/robertklep/mongo-cli
Last synced: 9 months ago
JSON representation
Query MongoDB from CLI
- Host: GitHub
- URL: https://github.com/robertklep/mongo-cli
- Owner: robertklep
- Created: 2014-06-03T09:47:03.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-01-06T08:50:18.000Z (over 11 years ago)
- Last Synced: 2025-02-15T02:43:05.224Z (over 1 year ago)
- Language: JavaScript
- Size: 168 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mongo-cli v1.0.1
CLI tool for [MongoDB](http://www.mongodb.com/)
## Install
```
npm install robertklep/mongo-cli -g
```
## Usage
```
$ mongo-cli [fields] [options]
url MongoDB URL
collection MongoDB collection to query
query Query to run (e.g. "{ _id : ObjectId(...) }")
fields Fields to return (e.g. "{ _id : 1 }")
Options:
-l NUM, --limit NUM Limit number of results
-s NUM, --skip NUM Skip first NUM results
-S OBJ, --sort OBJ Sort results
-H OBJ, --hint OBJ Force a specific index to be used
-e, --explain Return explanation of query [false]
```
For example:
```
$ mongocli mongodb://localhost/test users '{ name : "Jack" }' '{ _id : 1 }' --limit 10
```
## Notes
* `QUERY` and `FIELDS` don't have to be valid JSON (they do have to be valid JS, though)
* You can use `ObjectId()` in `QUERY`
* Output is unformatted JSON; if you want to pretty-print or to process further, take a look at [jq](http://stedolan.github.io/jq/)