Hello all,
I am trying to do a query where my parent object is related to a list of child items and I am looking to select all items that has all the items I am looking for, vs any of them.
I see that the where clause supports IN list
https://backendless.com/docs/js/data_search_with_where_clause.html
and the documentation clearly shows that this is using an OR operator between each item, and this is cool and all however what I want is the following
give me all carts that contains items with apples AND oranges
right now I can only do the following with the IN command
give me all carts that contains items with apples OR oranges
I do see that logically the IN is being compared on the child item level (apple is apple or orange), thus why my attempt to create an AND query by hand returns no matches (apple is apple and orange), so the actual comparer I am looking for is on the parent collection where I want to compare all children and only match when the number of matched children matches the number of comparers I am looking for (# of matched children = # of list items).
Is this possible? One way that I may do this in SQL would be to do a query for each (all carts with apple, all carts with oranges) then return carts from the first query that also exist IN the subsequent query. My gut tells me that this may work, but there is likely a much cleaner way via aggregates, groups and the having clause, however I am coming up short.
Have I over complicated the issue or am I missing something obvious? Any advice would be great, I have a very large collection of objects and I would like to get subsets that contain one or more related items.
Thanks a ton.