Parse Cloud Code relational query syntax Parse Cloud Code relational query syntax javascript javascript

Parse Cloud Code relational query syntax


This stretch:

// Also only fetch if never been sent before // HERE SHOULD USE THE BELOW RELATIONSHIPvar innerQuery = new Parse.Query(Parse.User);innerQuery.exists(Parse.User);query.matchesQuery("sentTo", innerQuery);

Could be changed to:

// Also only fetch if never been sent before query.notContainedIn("sentTo",[Parse.User.current()])

That works.Parse Query


what about Query Constraints?

If you want to retrieve objects that do not match any of several values you can use notContainedIn

  // Finds objects from anyone who is neither Jonathan, Dario, nor Shawnquery.notContainedIn("playerName",                     ["Jonathan Walsh", "Dario Wunsch", "Shawn Simon"]);


I think Kerem has it partially correct but notContained in is not dynamic enough for your case.

You need to construct the query from the relation and then use doesNotMatchKeyInQuery to exclude those objects from your outer query.