I need to write a MongoDB query of the form "A OR B OR (C AND D)" to return some records. We are using Mongoid for data access to our models.
I expanded that query to "(A OR B OR C) AND (A OR B OR D)" and was hoping that using Mongoid's Criteria method any_of
like this: Model.any_of(A, B, C).any_of(A, B, D)
would accomplish what I want, but that is expanded as "A OR B OR C OR A OR B OR D" before being sent to the database.
Is there a way to build this query, or do I have to build one query to do A OR B and another to do C AND D and take the union of them?