I am trying to implement server side pagination, that's why I used Pagination-v2
plugin which is fetching data from MongoDB server and appending into data table but now the problem is, after fetching the data.T he searching option is not working.I tried to use plugins Populate method but still it is not working. Please help me to solve this searching issue.
NodeJS code.
app.get('/gettable',(req,res)=>{
console.log(req.query);
user.paginate({},{
page:Math.ceil(req.query.start / req.query.length) + 1,
limit:parseInt(req.query.length),
populate:{
match:{
name:'Graiden Waller'
}
}
},function(err,result){
console.log(result);
var mytable = {
draw:req.query.draw,
recordsTotal:0,
recordsFiltered:0,
data:[],
}
if(err) {
console.log(err);
res.json(mytable);
} else {
if(result.totalDocs > 0) {
mytable.recordsTotal = result.totalDocs;
mytable.recordsFiltered = result.totalDocs;
for(var key in result.docs) {
mytable.data.push([
result.docs[key]['name'],
result.docs[key]['lastname'],
result.docs[key]['email'],
result.docs[key]['pass'],
result.docs[key]['birthdate'],
result.docs[key]['zipcode'],
result.docs[key]['phonenumber'],
]);
}
}
res.json(mytable);
}
}); });
as per my logic ,it should show me data related to name:"Graiden Waller" but its giving count function error.Please suggest me any other way to do searching in data table or please suggest me any other plugin to do this.Thank you Current plugins github repository is Mongoose-pagination-v2