S
S
Sergey2021-01-16 21:53:02
JavaScript
Sergey, 2021-01-16 21:53:02

How to get (filter) a specific number (from/to) of Firebase Realtime Database records?

Is there a way to filter posts from the Firebase database, for example by tag, so that posts from 5 to 10 are selected (for pagination)?

Here is the structure of the database:
600333875747e158310521.png

Here is the query:

loadPostsByTag(tag) {
    return this._database
      .ref("/portfolio/")
      .orderByChild("tags/" + tag)
      .equalTo(true)
      .limitToFirst(5)
      .once("value")
      .then((snap) => Object.values(snap.val()));
}


If you specify the startAt('5') parameter, then an error is generated that equalTo and startAt cannot be used in the same query...
60033528b2bf2607879666.png

Question: Is there any way to filter records in this way immediately when querying the database, rather than getting all the records at once and filtering on the client?
Thanks!)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question