我发现了一个用Rogue
写的代码
Rogue is a type-safe internal Scala DSL for constructing and executing find and modify commands against MongoDB in the Lift web framework
我发现用scala
编写的代码是查询数据
我希望将该代码转换为mysql
查询
def getBlogScore(word: String, blog: String): Long = Keyword.where(_.word eqs word).and(_.blog eqs blog)
.fetch.map(_.score._1)
.reduceLeftOption(_ + _).getOrElse(0)
给我一些想法!
答案 0 :(得分:1)
由于.reduceLeft( _ + _ )
会将所有分数加在一起,这可能就是您所需要的:
SELECT SUM(score)
FROM keyword
WHERE blog = 'blog'
AND word = 'word'