I am trying to find a way to do an OR query in a collection of "object" documents.
Each object document has a "type" field which is an array.
object1:
- name:
- description:
- types:["type-a","type-b","type-d"]
- createdOn
object2:
- name:
- description:
- types:["type-a","type-d"]
- createdOn
object3:
- name:
- description:
- types:["type-d","type-h"]
- createdOn
object4:
- name:
- description:
- types:["type-b"]
- createdOn
How can I do a query such that I get the object documents that either belongs to type-a or type-b? For example, for the above case of a collection, the result should be object1,object2,object4 ordered by createdOn field if possible.
Note that there are millions of "object" documents. So the operations should be as efficient as possible performance-wise, cost-wise, data transfer rate wise (battery life for a mobile app).
Very much appreciated!