Creates a new Db instance
The MongoClient for the database.
The name of the database this instance represents.
Optional settings for Db construction
The current readPreference of the Db. If not explicitly defined for this Db, will be inherited from the parent MongoClient
Check if a secondary can be used (because the read preference is not set to primary)
slaveOk specified
Add a user to the database
The username for the new user
Return the Admin db instance
Execute an aggregation framework pipeline against the database, needs MongoDB >= 3.6
An array of aggregation stages to be executed
Optional settings for the command
Returns a reference to a MongoDB Collection. If it does not exist it will be created implicitly.
the collection name we wish to access.
return the new Collection instance
Fetch all collections for the current db.
Execute a command
The command to run
Create a new collection on a server with the specified options. Use this to create capped collections. More information about command options available at https://docs.mongodb.com/manual/reference/command/create/
The name of the collection to create
Optional settings for the command
Creates an index on the db and collection.
Name of the collection to create the index on.
Specify the field to index, or an index specification
Drop a collection from the database, removing it permanently. New accesses will create a new collection.
Name of collection to drop
Drop a database, removing it permanently from the server.
Return the db logger
Retrieves this collections index info.
The name of the collection.
List all collections of this database with optional filter
Query to filter collections by
Optional settings for the command
Retrieve the current profiling Level for MongoDB
Remove a user from a database
The username to remove
Rename a collection.
Name of current collection to rename
New name of of the collection
Set the current profiling level of MongoDB
The new profiling level (off, slow_only, all).
Get all the db statistics.
Unref all sockets
Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this database. Will ignore all changes to system collections.
Type of the data being detected by the change stream
Type of the whole change stream document emitted
An array of aggregation pipeline stages through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
Optional settings for the command
Generated using TypeDoc
The Db class is a class that represents a MongoDB Database.