The mongo shell provides a JavaScript API for database operations. In the mongo shell, db is the variable that references the current database. The variable is automatically set to the default database test or is set when you use the use <db> to switch current database. The following table displays some common JavaScript operations: Basic Shell JavaScript Operations MongoDB Documentation, Release 3.0.4 For more information on performing operations in the shell, see: Changed in version 2.2. The mongo shell provides most keyboard shortcuts similar to those found in the bash shell or in Emacs. For some functions mongo provides multiple key bindings, to accommodate several familiar paradigms. The following table enumerates the keystrokes supported by the mongo shell: Keyboard Shortcuts • MongoDB CRUD Concepts (page 60) • Read Operations (page 60) • Write Operations (page 73) • js-administrative-methods 279 5.2. Administration Tutorials JavaScript Database Operations Description db.auth() If running in secure mode, authenticate the user. coll = db.<collection> Set a specific collection in the current database to a vari- able coll , as in the following example: coll = db.myCollection; You can perform operations on the myCollection using the variable, as in the following example: coll.find(); find() Find all documents in the collection and returns a cursor. See the db.collection.find() and Query Docu- ments (page 96) for more information and examples. See Cursors (page 64) for additional information on cur- sor handling in the mongo shell. insert() Insert a new document into the collection. update() Update an existing document in the collection. See Write Operations (page 73) for more information. save() Insert either a new document or update an existing doc- ument in the collection. See Write Operations (page 73) for more information. remove() Delete documents from the collection. See Write Operations (page 73) for more information. drop() Drops or removes completely the collection. createIndex() Create a new index on the collection if the index does not exist; otherwise, the operation has no effect. db.getSiblingDB() Return a reference to another database using this same connection without explicitly switching the current database. This allows for cross database queries. See How can I access different databases temporarily? (page 756) for more information.