En tant qu'utilisateur de sous-ensemble, j'aimerais produire une requête contenant deux points, mais je ne la fais pas à la volée. Permettez-moi d'améliorer votre exemple BlogPost http://osinka.github.com/subset/Subset+Query.html pour démontrer ce que je veux atteindre, même si elle n'a pas de sens de cette façon:Comment réaliser la notation par points en cascade MongoDB DBObject via osinka.subset
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
Comment puis-je produire un dbobject { "comments.text.subText" : "X"}
?
Merci, Peter
Génial! Ça fonctionne et j'aime cela. –
Je suis content d'entendre ça! Acceptez la réponse, s'il vous plaît –