How do we handle the queries in our server side?
How do we handle the queries in our server side?
I've a problem with too many queries that produced by datatable.
Here's the get url sample:
GET /api/v1/users/list?level=3&sEcho=1&iColumns=7&sColumns=%2C%2C%2C%2C%2C%2C&iDisplayStart=0&iDisplayLength=10&mDataProp_0=function&sSearch_0=&bRegex_0=false&bSearchable_0=true&bSortable_0=false&mDataProp_1%5Bfirstname%5D=firstname&mDataProp_1%5Blastname%5D=lastname&sSearch_1=&bRegex_1=false&bSearchable_1=true&bSortable_1=true&mDataProp_2%5B_id%5D=_id&mDataProp_2%5Busername%5D=username&sSearch_2=&bRegex_2=false&bSearchable_2=true&bSortable_2=true&mDataProp_3%5Blevel%5D=level&mDataProp_3%5Bfacebook%5D=facebook&mDataProp_3%5Btwitter%5D=twitter&mDataProp_3%5Binstagram%5D=instagram&mDataProp_3%5Byoutube%5D=youtube&mDataProp_3%5Bcompanyname%5D=companyname&mDataProp_3%5Bcontactnumber%5D=contactnumber&sSearch_3=&bRegex_3=false&bSearchable_3=true&bSortable_3=true&mDataProp_4=email&sSearch_4=&bRegex_4=false&bSearchable_4=true&bSortable_4=true&mDataProp_5=is_confirm&sSearch_5=&bRegex_5=false&bSearchable_5=true&bSortable_5=false&mDataProp_6%5Blevel%5D=level&mDataProp_6%5Bis_active%5D=is_active&sSearch_6=&bRegex_6=false&bSearchable_6=true&bSortable_6=false&sSearch=&bRegex=false&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&_=1411374459314
Is there any best way to handle this queries? Do we need to handle the query one by one?
I'm using node.js, here's my server-side code
if(req.query.iDisplayLength > 0) {
limit = req.query.iDisplayLength
}
if(req.query.iDisplayStart > 0) {
skip = req.query.iDisplayStart
}
User
.find(condition, '-hashed_password -salt -__v -reset_password_token')
.sort({'created': 1})
.limit(limit)
.skip(skip)
.exec(function (err, users) {
if (err) return errHelper.errorMongo(err, res)
return functionHelper.responseSuccess(res, users)
})
Anyone can help, because mostly example is in php codes?