문제

How can I do a nested and/or query in casbah?

For example:

val q =  $and( "a"->"b", $or("e"->"f", "e"->"g"), $or("c"->"d", "c"->"e") )

This sample doesn't compile, but that's the idea I'm trying to achieve.

도움이 되었습니까?

해결책

Documentation says: "$or operator performs a logical OR operation on an array of two or more expressions ", as it is array you should use Seq to delimit conditions.

coll.find(MongoDBObject("a"->"b","$or"->Seq(Map("e"->"f"),Map( "e"->"g")),"$or"->Seq(Map("c"->"d"),Map( "c"->"e"))))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top