Nested query DSL in casbah?

497 views Asked by At

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.

1

There are 1 answers

0
grotrianster On BEST ANSWER

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"))))