2

My parse class has a property called "postcodes", which is an array of numbers.

In my app, I have an array of "relevantPostcodes". I want to create a query where the postcodes key contains any object from the "relevantPostcodes" array.

Something like [query whereKey:@"postcodes" containsAnyObjectInArray:relevantPostcodes"]. Any ideas?

2
  • Did you ever figure this out, it still seems as though this doesn't work all too reliably. Would love if you could help mate. Commented Mar 1, 2018 at 2:29
  • EDIT - I stand corrected, the 'containedIn' method works perfectly. My dataset was incorrect. Commented Mar 1, 2018 at 2:34

1 Answer 1

5

You can use [query whereKey:@"postcodes" containedIn:relevantPostcodes]. See the description in the doc. Just like the equal to methods, I think it will operate on array type attributes and do what you need.

Sign up to request clarification or add additional context in comments.

5 Comments

I thought this was the case, but it wasn't working for me. I just did some further testing and it appears to work in a normal query, but not when [query fromLocalDatastore]. Same code with same constraints returns results from the cloud, but none from the local datastore, even after confirming the data is the same. Curious. Either a bug or I'm missing something.
I can't think of a reason other than bug why the same query on the same data would generate different results locally vs remotely.
Yes, I flagged it and they just confirmed it's a bug.
Can we have two containedIn, for two separate keys, in one query? query.containedIn("Key1", [2,3,4]); query.containedIn("Key2", [7,8,9]);
@AceGreen - I don't see why not. Should be easy to test out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.