MongoDB Documentation, Release 3.0.4 See Query Documents (page 96) and Read Operations (page 60) documentation for more information and examples. See http://docs.mongodb.org/manual/reference/operator/query to specify other query opera- tors. Changed in version 2.6. The mongo shell write methods now integrates the Write Concern (page 78) directly into the method execution rather than with a separate db.getLastError() method. As such, the write methods now return a WriteResult() object that contains the results of the operation, including any write errors and write concern errors. Previous versions used db.getLastError() and db.getLastErrorObj() methods to return error informa- tion. The following table lists some common methods to support database administration: Error Checking Methods Administrative Command Helpers See also administrative database methods for a full list of methods. You can create new connections within the mongo shell. The following table displays the methods to create the connections: Opening Additional Connections See also Opening New Connections (page 270) for more information on the opening new connections from the mongo shell. JavaScript Connection Create Methods Description db = connect("<host><:port>/<dbname>") Open a new database connection. conn = new Mongo() db = conn.getDB("dbname") Open a connection to a new server using new Mongo() . Use getDB() method of the connection to select a database. Chapter 5. Administration 282 JavaScript Database Administration Methods Description db.cloneDatabase(<host>) Clone the current database from the <host> specified. The <host> database instance must be in noauth mode. db.copyDatabase(<from>, <to>, <host>) Copy the <from> database from the <host> to the <to> database on the current server. The <host> database instance must be in noauth mode. db.fromColl.renameCollection(<toColl>) Rename collection from fromColl to <toColl> . db.repairDatabase() Repair and compact the current database. This operation can be very slow on large databases. db.getCollectionNames() Get the list of all collections in the current database. db.dropDatabase() Drops the current database.