The mongo
shell includes an embedded JavaScript interpreter which allows building custom extensions and helper functions.
Documentation for working with the mongo
shell:
This repo includes some common extensions and functions for the mongo
shell. There is currently no standard way to package or install shell extensions, so you will have to check the README in the relevant repo.
To check out all extensions, you can clone this repository using: git clone --recursive ...
git submodule update --remote
- Most of the shell extensions have been independently developed, so functionality may overlap and/or conflict
- Some extensions override built-in
mongo
shell API (as opposed to augment), and may inadvertently cause different behaviour from the default shell - Run
mongo --norc
to start a shell session without loading any startup scripts
These extensions include a grab-bag of improvements.
Extension | Author | Purpose |
---|---|---|
mongo-hacker | TylerBrock | MongoDB Shell Enhancements for Hackers: colorized query output, custom prompt, API additions (eg. fluent aggregation) ... |
mongodb-shell-extensions | gabrielelana | A bundle of utility libraries and API additions including: MomentJS, LoDash, JSONPath, and sprintf.js |
mongorcd | devkev | Automatically load multiple mongo shell startup scripts from the ~/.mongorc.d directory. Includes a great set of example scripts. |
These extensions provide discrete features which extend built-in objects.
Extension | Author | Purpose |
---|---|---|
mongodb-schema | skratchdot | Schema analysis tool; adds db.collection.schema() |
mongo-table-view | cswanson310 | Display results of a cursor in a table view; adds .table() method for find() and aggregate() . |
mongodb-distinct-types | skratchdot | Similar to the db.myCollection.distinct() function, distinctTypes() will return "types" rather than "values"; adds db.collection.distinctTypes() . |
mongodb-wild | skratchdot | Adds a wildcard search to collection or query results; adds db.collection.wild() , db.collection.find().wild() . |
Additional functions designed to be invoked in the mongo
shell.
Library | Author | Purpose |
---|---|---|
uuidhelpers.js | mongo-csharp-driver | Javascript helper functions for parsing and displaying historical UUID variations in the MongoDB shell; includes HexToBase64() , Base64ToHex() , UUID() , JUUID() , CSUUID() , PYUUID() |
Third party JavaScript libraries which are compatible with the mongo
shell (but not specifically designed for it).
Library | Purpose |
---|---|
Moment.js | Parse, validate, manipulate, and display dates in JavaScript. |
JSONPath | Analyse, transform, and selectively extract data from JSON documents (and JavaScript objects) using JSONPath. |
Underscore | Underscore provides over 100 functions that support both your favorite workaday functional helpers: map, filter, invoke — as well as more specialized goodies: function binding, javascript templating, creating quick indexes, deep equality testing, and so on. |
Lo-Dash | A utility library that began as a fork of Underscore and has since become a superset of Underscores features. |
sprintf.js | A complete open source JavaScript sprintf implementation. |