O'Reilly logo

Web Development with MongoDB and Node.js by Jason Krol

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The basics of MongoDB

Since MongoDB is largely powered by JavaScript, the mongo shell acts as a JavaScript environment. In addition to being able to execute regular Mongo queries, you can also execute standard JavaScript statements. Most of the items mentioned earlier in the JavaScript primer apply directly to the mongo shell as well.

In this next section, we will focus primarily on the various ways to perform standard create, read, update, delete (CRUD) operations via the mongo shell.

The mongo shell

To access the mongo shell, simply execute mongo from any terminal. The mongo shell requires the mongod server to be currently running and available on the machine as the first thing it does is connect to the server:

$ mongo
MongoDB shell version: 2.4.5 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required