exports.getAllStudent = function (req, res) {
//
var rows = url.parse(req.url, true).query.rows;
var page = url.parse(req.url, true).query.page;
var sidx = url.parse(req.url, true).query.sidx;
var sord = url.parse(req.url, true).query.sord;
var sordNumber = sord == "asc" ? 1 : -1;
//
Student.count({}, function (err, count) {
//
console.log(count)
var total = Math.ceil(count / rows);
console.log(total)
var sortobj = {};
//
sortobj[sidx] = sordNumber;
//
//recordspagetotalrowsjqGrid
// http://blog.mn886.net/jqGrid/ demo
//API:http://blog.mn886.net/jqGrid/JSONData
/* Student.find({},function (err,results) {
//console.log(results);
res.json({"records" : count, "page" : page, "total" : total , "rows" : results});
});*/
/*.sort(sortobj)*/
Student.find({}).limit(rows).skip(rows * (page - 1)).exec(function (err, results) {
console.log(rows,page);
console.log(results)
res.json({"records": count, "page": page, "total": total, "rows": results});
});
});
};