How to know if I'm returning the last set of document/documents of a collection?
For now I keep the full document count as reference to check if I received the all the records.
I'm using skip with limit for lazy loading. Is there a better way to do this ?
You can, as confirmed by @Abhishek Anand
You can also fetch limit+1 documents, and only return min(n documents found, limit)
This way you avoid a count, and you know you reached the end of collection whenever you don't have limit+1 documents found
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.