Facebook Pixel

How do you know if there is more data in cursor pagination?

Fetch limit + 1 items. If you get limit + 1, there is more (pop the extra). If you get limit or fewer, there is no more. Avoids a separate count query.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Feed API Design Interview Questions and Answers

GET /feed?skip=&limit=. Exclude the current user and already-swiped users. Build a filter from whitelisted query params. Use .lean() and .select(). Return { data, total, skip, limit }. Run find and countDocuments in parallel. Index the filter and sort fields.

Offset for small collections or when the client needs page numbers. Cursor for large collections or infinite scroll (faster, stable). Both need an index on the sort or cursor field.

Fetch the seen IDs with a distinct query. Filter the feed with _id: { $nin: seenIds }. For a dating app, exclude users the current user has already swiped on.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.