reactivemongo.extensions.json

dao

package dao

Visibility
  1. Public
  2. All

Type Members

  1. abstract class JsonDao[Model, ID] extends Dao[JSONCollection, JsObject, Model, ID, Writes]

    A DAO implementation that operates on JSONCollection using JsObject.

    A DAO implementation that operates on JSONCollection using JsObject.

    To create a DAO for a concrete model extend this class.

    Below is a sample model.

    import reactivemongo.bson.BSONObjectID
    import play.api.libs.json.Json
    import play.modules.reactivemongo.json.BSONFormats._
    
    case class Person(
      _id: BSONObjectID = BSONObjectID.generate,
      name: String,
      surname: String,
      age: Int)
    
    object Person {
      implicit val personFormat = Json.format[Person]
    }

    To define a JsonDao for the Person model you just need to extend JsonDao.

    import reactivemongo.api.{ MongoDriver, DB }
    import reactivemongo.bson.BSONObjectID
    import play.modules.reactivemongo.json.BSONFormats._
    import reactivemongo.extensions.json.dao.JsonDao
    import scala.concurrent.ExecutionContext.Implicits.global
    
    
    object MongoContext {
     val driver = new MongoDriver
     val connection = driver.connection(List("localhost"))
     def db(): DB = connection("reactivemongo-extensions")
    }
    
    object PersonDao extends JsonDao[Person, BSONObjectID](MongoContext.db, "persons")
    Model

    Type of the model that this DAO uses.

    ID

    Type of the ID field of the model.

  2. class JsonDaoBuilder[Model, ID] extends AnyRef

Value Members

  1. object JsonDao

  2. object JsonDaoBuilder

Ungrouped