reactivemongo.extensions.json.dao
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")
Type of the model that this DAO uses.
Type of the ID field of the model.
A parameterless function returning a reactivemongo.api.DB instance.
Name of the collection this DAO is going to operate on.
reactivemongo.extensions.dao.LifeCycle for the Model type.
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.
To define a JsonDao for the Person model you just need to extend JsonDao.
Type of the model that this DAO uses.
Type of the ID field of the model.