MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home
/ /
Connection Methods

Mongo.getDB()

Mongo.getDB(<database>)

Provides access to database objects from the mongo shell or from a JavaScript file.

The Mongo.getDB() method has the following parameter:

Parameter
Type
Description

database

string

The name of the database to access.

The following example instantiates a new connection to the MongoDB instance running on the localhost interface and returns a reference to "myDatabase":

db = new Mongo().getDB("myDatabase");

Tip

Back

Mongo()

On this page