Skip to content
Advertisement

Firestore GET all Boolean TRUE then append FALSE values

I need a request/ request flow that retrieves all the documents where the boolean is true and then gets all that is false.

Is there a firestore query I can make that does this? An orderBy?

Currently, I have an InfiniteScroll and I am struggling for the display to switch between getting true values to getting false values.

JavaScript

It seems the issue is currently it doesn’t switch between getting true to false seemlessly on ReactJs side. So a firestore query that fetches all true then false would be perfect as then I can use a regular pagination flow that I know works.

Advertisement

Answer

If you want only the documents where the onlyListed field value is true, you can use a query:

JavaScript

If you want all documents with the onlyListed field, no matter its value, but with them grouped by their value, you can use an ordered query:

JavaScript

If this gives the wrong order, you can reverse it by:

JavaScript
Advertisement