Frage

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.

War es hilfreich?

Lösung

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"))))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top