Pulling the firebase documents those that comes before/above the specified document

19 Views Asked by At

Is there a way we can pull the Firebase documents that comes before/above the specified document Id.?? If so can someone please suggest to me how I can achieve that? I'm using the ngx-pagination and I'm not pulling all the documents at once. Im pulling the data only when the next page has been hit and it's working fine by using the startAfter() method. I want to know if there are any predefined methods like startAfter() for pulling the documents that comes before the mentioned documentId.

1

There are 1 best solutions below

1
Frank van Puffelen On

The opposite of startAfter is a method called endBefore. You can pass in the same information as you'd pass to startAfter, but get the documents before the so-called cursor document.

For more on this, see the Firebase documentation on paginating with cursors and the reference documentation for endBefore.