MongoClient.getDatabase

Returns an object representing the specified database.

The returned object allows to access the database entity (which contains a set of collections). There are two main use cases:

1. Accessing collections using a relative path

2. Performing service commands on the database itself

Note that there is no performance gain in accessing collections via a relative path compared to getCollection and an absolute path.

class MongoClient
@safe
MongoDatabase
getDatabase
(
string dbName
)

Return Value

Type: MongoDatabase

MongoDatabase instance representing requested database

Examples

auto db = client.getDatabase("test");
auto coll = db["collection"];

Meta