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
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook