Amit
Amit

Reputation: 3990

mongodb and or combo

How do i do this in mongodb....

(a || b || c) || (d && e)

Upvotes: 0

Views: 683

Answers (1)

Michael Papile
Michael Papile

Reputation: 6856

(a || b || c) || (d && e) is equivalent to (a || b || c || (d && e))

if abcde are your fields and 12345 are the values (simple case you can put whatever as those expressions):

 db.foo.find( { $or : [ { a : 1 } , { b : 2 },{ c : 3 },{ d : 4 , e :5} ] } );

Note this is for mongodb >= 1.5.3 earlier ones do not have $or

Upvotes: 4

Related Questions