翻訳例:
サービス:
def countSentMailForVenue(currentId: Long, from: DateTime, to: DateTime) : Future[Int] = {
val query = Json.obj("venueInfo.currentId" -> venueId, "origin" -> Origin.EMAIL_INVITE, "updated" -> Json.obj("$gte" -> from.getMillis, "$lt" -> to.getMillis))
count(BSONFormats.toBSON(query).get.asInstanceOf[BSONDocument])
}
そしてダオでは:
/**
* Currently Count() only supports BSONDocument.
*/
def count(query: BSONDocument) : Future[Int] = {
Logger.debug(s"Counting documents: "+BSONFormats.toJSON(query))
val futureCount = collection.db.command(
Count(
collection.name,
Some(query)
)
)
futureCount
}