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

Query with IN operator? #79

Closed
socraticat opened this issue Apr 20, 2020 · 3 comments
Closed

Query with IN operator? #79

socraticat opened this issue Apr 20, 2020 · 3 comments

Comments

@socraticat
Copy link

socraticat commented Apr 20, 2020

Hi, thank you for this library as I've been using this for a small Firestore-Google Sheets project. I have a rather large collection of documents and I need to retrieve 10-20 at a time using the IN operator.

I'm not sure if I missed it in the docs but this doesn't seem to be supported yet. Is there an operator I can use to query something like: where field IN [1,2,3,4,5]?

@LaughDonor
Copy link
Collaborator

I apologize the documentation isn't clearly updated with this, but try out:

var results = db.query('path/to/collection').where('fieldName', 'contains', true).offset(0).limit(20).execute()

This will get first 20 documents with array fields named "fieldName" that contain a JS true value.

Is this what you're looking for?

@socraticat
Copy link
Author

socraticat commented May 4, 2020

Sorry, I should give a clearer explanation. I have a collection in 'path/to/collection' in which each item has a string ID field, let's say test1, test2, etc. There can be potentially hundreds of these items with unique IDs but I would like to query X at a time by providing an array of IDs like so (in SQL terms):

SELECT * FROM collection WHERE ID IN ("test1", "test2", "test3", "test4")

Also works if I can just query by the actual Document ID (or UID), I've made redundancies in case only one of them works.

@LaughDonor
Copy link
Collaborator

I see what you're getting at. This was missing, and I've released v24 that allows this.

Thanks for bringing this up!

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

2 participants