database.collection()¶
Definition¶
database.collection()
¶
Return a collection handle object that represents a collection in a
database
.
Usage¶
Example¶
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");
Parameters¶
The database.collection()
action has the following form:
collection(name)
Parameter | Description |
---|---|
Collection Name name: <string> | The name of the collection. The collection must exist in the
database associated with the database handle object. |
Return Value¶
The database.collection()
action returns a collection
object that allows you to query the specified collection.
Give Feedback