Navigation

mongodb.db()

mongodb.db()

Return a database handle object that represents a database in a linked MongoDB data source. Call database.collection() on the database handle to retrieve a collection handle.

To call the mongodb.db() action from a function, instantiate a MongoDB service client from context then call the client's db() method.

const mongodb = context.services.get("myMongoDBCluster");
const db = mongodb.db("myDB");

The db() action has the following form:

db(name)
Parameter
Description

Database Name

name: <string>
The name of the database. The database must exist in the linked cluster associated with the MongoDB service client.

The mongodb.db() action returns a database object that allows you to access collections in the specified database.

See database.collection()

Give Feedback