const messagesRef = collection(db, 'messages')
const q = query(messagesRef, orderBy('createdAt', 'asc'), limit(25))
Im querying documents in 'messages' collection by creation time, the problem with this is that when im trying to limit documents, it limits from the start, but i want to limit it from the end. I want that user would see newer messages but not the old ones.
CodePudding user response:
To get the last 25 items, use limitToLast(25)
instead of limit(25)
. While that function isn't mentioned in the guide on limiting data, you can find it in the reference documentation.