Navigation

database.collection()

database.collection()

Return a collection handle object that represents a collection in a database.

To call the database.collection() action from a function, get a database handle with mongodb.db() then call the handle's collection() method.

const collection = mongodb.db("myDB").collection("myCollection");

The database.collection() action has the following form:

collection(name)
ParameterDescription

Collection Name

name: <string>
The name of the collection. The collection must exist in the database associated with the database handle object.

The database.collection() action returns a collection object that allows you to query the specified collection.

Give Feedback