flamelink / flamelink-js-sdk

🦊 Official Flamelink JavaScript SDK for both the Firebase Realtime database and Cloud Firestore
https://flamelink.github.io/flamelink-js-sdk
MIT License
43 stars 5 forks source link

Logical 'OR' not possible when doing 'get' operation with filters #121

Closed NiklasMencke closed 4 years ago

NiklasMencke commented 4 years ago

Hey,

when using the javascript sdk and fetching content with filter options I want to do a logical OR instead of AND when combining filter operations

[ ['state', '==', 'CA'], ['state', '==', 'NY'] ]

so in this example I would want to retrieve entries where state is either NY OR CA. This should also be possible when querying different attributes at the same time, e.g

[ ['state', '==', 'CA'], ['city', '==', 'NYC'] ]

Currently it looks like only AND is possible?

jperasmus commented 4 years ago

Hi, apologies for the delay in response.

You can use Firestore's in operator to do this. Under the hood, the filters are passed to Firestore as where clauses.

filters: [
  ['state', 'in', ['CA', 'NY']]
]

Hope that helps.