[英]scala & mongoDB - how to count records with salat?
Is it possible to issue a count() query, with several conditions, using salat library? 是否可以使用salat库发出带有几个条件的count()查询?
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 但我相信一个计数会表现得更好
I had a look at salat sources and it was easier than expected 我看了salat来源 ,它比预期容易
def countByPoll(pollId: String, option: Int): Long = {
dao.count(MongoDBObject("pollId" -> pollId, "option" -> option))
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.