Mr. Octodood
Mr. Octodood

Reputation: 121

Limiting a Firebase Realtime Database Query

Is there any way that I can limit a Firebase Database Query to just one child or start at a certain child.

So for example:

I have a user's path with 10 children (which would be the USERS).

Upvotes: 0

Views: 1171

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599131

Yes there is are ways to limit what child nodes are read from a location, by using the Firebase query operations to order, filter and limit data.

But unlike what you seem to want, these queries are not offset based. So while you can get the first 3 child nodes matching certain conditions, you cannot subsequently request that Firebase skip the first 3. Instead, Firebase queries are cursor based, meaning they work from knowing what specific item to start at. What you can do is remember the 3rd item of the first page, and then tell Firebase to start returning child nodes from that one onwards.

If you search for Firebase queries and pagination you'll find a lot of material showing how to do this.

Also see:

Upvotes: 1

Related Questions