Is there a startBefore() function in Realtime Database?

Viewed 132

I am creating a messaging application where messages are stored like this: database structure

When the user goes onto the message, I uses .orderByKey().limitToLast(16) to get the 16 bottom-most messages. I am trying to add pagination, and I have the "highest" message key saved. However, when I run .orderByKey().limitToLast(16).startAfter(key), it returns the bottom-most 16 again. Is there function that can get the NEXT 16 last messages?

Thanks

1 Answers

I don't recall ever needing a startBefore() method for pagination. If your use-case is that the user scrolls back from the 16 most recent nodes, I think you may be looking for endBefore instead.

Related