作为一个子集用户,我想生成一个包含两个点的查询,但我不能即时完成。让我增强您的 BlogPost 示例http://osinka.github.com/subset/Subset+Query.html来演示我想要实现的目标,即使这样没有意义:
case class SubComment(subText: String)
case class Comment(by: String, votes: Int, text: SubComment)
case class BlogPost(title: String, comments: List[Comment])
object SubComment {
val text = "text".fieldOf[String]
implicit val writer = {
def f(sub: SubComment): DBObject = (text -> sub.subText)
ValueWriter(f _)
}
}
object Comment {
val by = "by".fieldOf[String]
val votes = "votes".fieldOf[Int]
val text = "text".fieldOf[SubComment]
}
object BlogPost {
val title = "title".fieldOf[String]
val comments = "comments".subset(Comment).of[List[Comment]]
}
val qComment = BlogPost.comments.where { _.by === "maria" }
val qSubComment = BlogPost.comments.where {…? === "X"} // not yet working
我怎样才能产生一个 DBObject { "comments.text.subText" : "X"}
?
谢谢,彼得