NoSQL Benchmarks NoSQL use cases NoSQL Videos NoSQL Hybrid Solutions NoSQL Presentations Big Data Hadoop MapReduce Pig Hive Flume Oozie Sqoop HDFS ZooKeeper Cascading Cascalog BigTable Cassandra HBase Hypertable Couchbase CouchDB MongoDB OrientDB RavenDB Jackrabbit Terrastore Amazon DynamoDB Redis Riak Project Voldemort Tokyo Cabinet Kyoto Cabinet memcached Amazon SimpleDB Datomic MemcacheDB M/DB GT.M Amazon Dynamo Dynomite Mnesia Yahoo! PNUTS/Sherpa Neo4j InfoGrid Sones GraphDB InfiniteGraph AllegroGraph MarkLogic Clustrix CouchDB Case Studies MongoDB Case Studies NoSQL at Adobe NoSQL at Facebook NoSQL at Twitter



MongoDB and the JavaScript Shell

If you’ve watched any of the MongoDB screencasts[1] you’ve probably already noticed the usage of the MongoDB interactive shell[2]. Recently, Mike Dirolf (@mdirolf) has published an ☞ article covering some of the details of the JavaScript based MongoDB interactive shell:

The embedded interpreter is used in all sorts of different ways, including for Map/Reduce, db.eval, and $where clauses. One nice feature supported by MongoDB is the ability to store JS functions on the server.

In ☞ an interview with the guys over ☞ The BitSource, Mike Dirolf commented about the MongoDB shell:

Q: Why write a shell in Javascript?

M.D.: We wanted the shell to be a full programming environment, a “real” programming language. That makes a lot of administrative tasks much easier. It also allows us to use it for automated testing and a wide variety of other use cases.

Once that decision was made the options were to invent our own language or pick an existing one. JavaScript is a good choice because it is flexible, full-featured, and widely known. Most web developers have at least a passing familiarity with JavaScript, if not deep expertise. It’s sort of a least common denominator programming language for the web, and that makes it a good choice for a general purpose tool like our shell.

Q: What is one cool thing it can do?

M.D.: The shell can do a lot of cool things – it’s a full MongoDB client! It can be used to perform any of the operations supported by any of the other MongoDB rivers, and you can do them from a nice REPL. This makes it incredibly easy to use for administration and just playing around with MongoDB.

Q: What is one thing the Javascript shell does exceptionally better than other code of it’s type? Would Oracle’s sqlplus be the comparison of the Javascript shell in MongoDB, for example?

M.D.: Yeah I think those are comparable. The really nice thing about the shell compared to other DB shells is that it is really a fully functioning programming language. You can do all sorts of interesting things by leveraging that fact – you can write real programs to do administrative tasks.

We should note that there are more NoSQL projects using JavaScript for server side work (f.e. CouchDB and Riak), while ☞ others are looking into some more exotic options like Tcl.