0

I have User class and Follow class. User is the standard Parse User class. My Follow class contains the follower and followed columns, both pointers to User instances.

I am trying to return a list of Users which are not followed by my user. I know I can get the follows first and then locally call notContainedIn, but it involves loading the array first locally. I want to execute my query in "one shot" (at least in my code side). This is my current code:

var recommendedPeopleQuery = new Parse.Query(User);
[...]
var user = request.user;
var followingsQuery = new Parse.Query("Follow");
followingsQuery.equalTo("follower", user);
recommendedPeopleQuery.???? //it should exclude
                            //followingsQuery's "followed" results.

What should the last line be?

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • Can you use Cloud Code to chain the queries together in the cloud before returning the dataset to the client? – mbm29414 Jan 27 '15 at 01:40
  • @mbm29414 Yes, I can do it using the promise pattern/backbone style completion handlers. But it usually overcomplicates the code and reduces readibility. I'm looking for a cleaner solution that will just give me what I want as a result of query. I know inner queries work in Parse (e.g. `matchesKeyInQuery`) so it should be technically possible to finish in a single query with a subquery. – Can Poyrazoğlu Jan 27 '15 at 15:15
  • 1
    I scoured the Parse documentation for a while thinking about this issue, and I am now convinced that Parse has not yet enabled query features to accomplish this in one query. I **did** come up with a Promise-based Cloud Code function to accomplish this that wasn't terribly over-complicated. – mbm29414 Jan 27 '15 at 19:20
  • @mbm29414 Sad to see such a feature (which has the technical ground ready) is missing in Parse SDK. Anyway, I'll go with the promise pattern. – Can Poyrazoğlu Jan 27 '15 at 20:00
  • 1
    Yeah, I agree, but they **do** continue improving the platform. I'd make a feature request. It's a very reasonable feature to request! ;-) – mbm29414 Jan 27 '15 at 22:12
  • @mbm29414 You are right. They are getting better everyday. I'll post it to Google Group. – Can Poyrazoğlu Jan 27 '15 at 22:13

0 Answers0