I'm thinking you want things defined like this, to prevent multiple MongoDriver
and connection pools from being created:
object PersistenceManager{
val driver = new MongoDriver
val connection = driver.connection(List("localhost"))
}
trait PersistenceManager {
import PersistenceManager._
def loan[A](collectionName: String)(f: BSONCollection => Future[A]): Future[A] = {
val db = connection("flujo_caja_db")
val collection = db.collection(collectionName)
f(collection)
}
}