4

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

opensas
  • 60,462
  • 79
  • 252
  • 386

1 Answers1

5

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))
}
opensas
  • 60,462
  • 79
  • 252
  • 386