db.getCollection(name) in mongoDB

getCollection(name)

This method returns a collection object that is functionally equivalent to using the db.<collectionName> syntax.

The method is useful for a collection whose name might interact with the shell itself, such as names that begin with _ or that match a database shell method.


Syntax:

db.getCollection(collectionName)


Example

MongoDB

db.getCollection("movies")

Output:

example.movies


No comments:

Post a Comment