connectMongoDb method

Future<Db> connectMongoDb()

Connects to MongoDB using the connection string from the configuration.

If config.dbConfig.enable is true, the database connection is opened.

Returns a Future containing the mongo.Db instance.

Implementation

Future<mongo.Db> connectMongoDb() async {
  var db = mongo.Db(config.dbConfig.link);
  if (config.dbConfig.enable) await db.open();
  return db;
}