I have two schema say city and blogs. I want to create a blog page with pagination. So I am populating blogs with reference to city name. Say if I dont have a blog for a city then it should not be returned. Here is my query to get the blogs.
City.find().skip(req.params.pageIndex*2).limit(2).sort('-created').populate('articles').exec(function(err, cities) {
res.jsonp(cities)
}
If I use the above query. I get the cities with no blogs as well. So it results in an empty row in the view. I don't want that to happen. How to limit the populated field and not return the city without blogs. Any suggestions?