mongoose-paginate
mongoose-paginate copied to clipboard
lean option is not behaving correctly
I am using mongoose-paginate for pagination in my api with lean option. But lean option is not sending data in javascript , as another part of code runs over api data is not functioning.
userContent.paginate({},{lean:true,leanWithId:false,limit:10,page:req.params.pages,populate:({path:'user_id', select:"_id firstname device_id profile_pic"})},function (err, posts) {
//userContent.find({}).lean().exec(function(err,posts){
if(err) {
res.statusCode = 500;
return res.send({ error : err });
}
else{
var i = -1;
var next = function(){
i++;
if(i<posts.length){
var post = posts[i];
postsLike.findOne({post_id : post._id,user_id:req.params.user_id}, function(err, postLikes){
post.like = "no";
if(postLikes){
post.like = "yes";
}
next();
});
}else{
res.json(posts);
}
}
next();
}
});
});