Constrain query to match item in an array with any item in an array?

Hello everyone,

I have users with a key called “interests” where I store an array of arrays of strings ([[String]]), where each inner array is an interest composed of three strings, and another key called “interestsFilter”, with the same structure. How would I constrain a query so that I get the users that have any array interests match any array in interestFilter?

For example:
User1 has:
interests: [[“Soccer”, “Goalkeeper”, “Beginner”], [“Baseball”, “Pitcher”, “Advanced”]]
CurrentUser has:
interestsFilter: [[“Baseball”,“Catcher”,“Advanced”],[“Soccer”,“Goalkeeper”,“Beginner”]]

User1’s interests[0] matches CurrentUser’s interestsFilter[1], so the query would return user1.


I believe that query.containedIn('interests',[[“Baseball”,“Catcher”,“Advanced”],[“Soccer”,“Goalkeeper”,“Beginner”]] should do what you need.

Just tested it. Sadly, this would only work if ‘interests’ stored an array of strings instead of an array of arrays of strings.

You will probably have to use aggregate: JavaScript Developers Guide | Parse

1 Like