Domanda

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.

È stato utile?

Soluzione

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"))))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top