bind[DB] identifiedBy 'db toNonLazy {
val driver = new reactivemongo.api.MongoDriver
val dbT: Try[DB] = MongoConnection.parseURI(uri).map { parsedUri =>
val connection = driver.connection(parsedUri)
connection.db(parsedUri.db.get)
}
dbT match {
case Success(db) => db
case Failure(ex) => throw new RuntimeException(ex)
}
}
bind[DB] identifiedBy 'db toNonLazy {
val driver = new reactivemongo.api.MongoDriver
val dbT: Try[DB] = MongoConnection.parseURI(inject[String](identified by "mongodb.uri")).map { parsedUri =>
val connection = driver.connection(parsedUri)
connection.db(parsedUri.db.get)
}
dbT match {
case Success(db) => db
case Failure(ex) => throw new RuntimeException(ex)
}
}
lazy val reactiveMongoApi = inject[ReactiveMongoApi]
def collection = reactiveMongoApi.db.collection[BSONCollection]("collectionName")