Tuesday 9 February 2016

Creating paging with 2 mongoose collection

I wan't to do paging with 2 different mongodb collections like let's say I have some text on one collection and some pictures (or urls to those pictures) in another and I need to send 10 in total of those back to user, so if user makes api reguest like GET /api/feed/1 it sends first 10 images or texts sorted by date. So if user creates 3 texts first then 8 images it would send 2 texts and 8 images back. How do I combine those two collections to work like that? I could easily do this with limit if I would use only 1 collection but how about with 2? Sorry for bad explanation, I am very tired at the moment, hopefully you guys get what I want :)

Submitted February 09, 2016 at 05:02PM by Viped

No comments:

Post a Comment