DatabaseProvider is the central repository for MongoClient, registries, databases and collections.

DatabaseProvider gives access to

  • MongoClient
  • MongoDatabase
  • MongoCollection



Additional Info for Registries

Create Case Classes

sourcecase class Student(_id: Long, name: String, scores: List[Score])

case class Score(score: Double, `type`: String)

case class Grade(_id: ObjectId, student_id: Long, class_id: Long, scores: List[Score])

Create Registry

sourceval registry: CodecRegistry =
  fromProviders(classOf[Student], classOf[Score], classOf[Grade])

val providerWithRegistry: DatabaseProvider =
  DatabaseProvider(MongoConfig.fromPath(), registry)

Multiple databases access