MongoDB: db.getCollection() method
db.getCollection
The db.getCollection() method is used to return a collection object.
Syntax:
db.getCollection(name)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
name | The name of the collection. | Optional | string |
Example: MongoDB: db.getCollection() method
The following example will return the name of the collection object 'orders' in the test database.
db.getCollection('orders')
Output:
> db.getCollection('orders') test.orders
Retrieve the restaurants data from here
Previous:
db.fsyncUnlock() method
Next:
db.getCollectionNames() method
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/mongodb/shell-methods/database/db-getCollection.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics