1

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.

Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
Greg
  • 10,696
  • 22
  • 68
  • 98
  • A 3 year user with 45 questions shouldn't still be signing questions!! I have fixed **all** your questions. You need to read help section of the site, this post on meta is also relevant *(from Jeff Atwood himself)* http://meta.stackexchange.com/a/93989/180280 – Chris Seymour Dec 17 '13 at 16:46

1 Answers1

0

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"))))
grotrianster
  • 2,468
  • 14
  • 14