Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support query combination "and" #376

Closed
josephchow102 opened this issue Jan 18, 2018 · 3 comments
Closed

Support query combination "and" #376

josephchow102 opened this issue Jan 18, 2018 · 3 comments

Comments

@josephchow102
Copy link

Currently, queries are combined by AND by default, and can combine two queries with OR through .or(q1, q2). However, since there is no .and(q1, q2), some use cases are not covered or become over-complicated.

  1. (q1 OR q2) AND q3:
let q1 = new Query(Table).equalsTo('field1', 'value1')
let q2 = new Query(Table).equalsTo('field1', 'value2')
let oredQuery = Query.or(q1, q2)
let q3 = oredQuery.equalsTo('field2', 'value3')
  1. q1 AND (q2 OR q3): not supported

  2. (q1 OR q2) AND (q3 OR q4) AND q5: not supported

  3. (q1 OR q2) AND (q3 OR q4) AND ... AND qN: not supported

@carmenlau
Copy link
Contributor

+1 for CMS references filter support. We need combine the or references predicates with the original query

@Steven-Chan
Copy link

Steven-Chan commented Jun 4, 2018

no change needed in skygeario/skygear-sdk-ios since NSPredicate support NSCompoundPredicate natively.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name = %@ && age >= %d", @"Peter", 12];

is the same as

NSPredicate *p1 = [NSPredicate predicateWithFormat:@"name = %@", @"Peter"];
NSPredicate *p2 = [NSPredicate predicateWithFormat:@"age >= %d", 12];
NSPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[p1, p2]];

@carmenlau
Copy link
Contributor

@Steven-Chan I just merged the android SDK update, would like to know is there any update for JS SDK? Cannot find the relates PR :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants