db property

Db get db

Gets the MongoDB database instance.

If the database is not connected, this method will attempt to connect to MongoDB. Throws an exception if the database is not running.

Implementation

mongo.Db get db {
  if (_db == null) {
    connectMongoDb().then((value) => _db = value);
    throw ('Error DB is not running');
  }

  return _db!;
}