Frage

Is it possible to issue a count() query, with several conditions, using salat library?

right now I'm just doing something like

def countByPoll(pollId: String, option: Int): Int = {
  dao.find(
    MongoDBObject("pollId" -> pollId, "option" -> option)
  ).size
}

But I'm sure a count would perform much better

War es hilfreich?

Lösung

I had a look at salat sources and it was easier than expected

def countByPoll(pollId: String, option: Int): Long = {
  dao.count(MongoDBObject("pollId" -> pollId, "option" -> option))
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top