get query criteria in rest api in a elegant way?

I recently building a restapi service using nodejs & mongodb(using mongoose for ORM) & express. I have read parse.com to design my api. also mongodb http interface

curl -X GET \
  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
  -G \
  --data-urlencode 'where={"score":{"$gte":1000,"$lte":3000}}' \
  https://api.parse.com/1/classes/GameScore


http://127.0.0.1:28017/databaseName/collectionName/?filter_a=1&limit=-10 //url example:

Question 1:

  • Do I have to parse the query by mapping the mongodb query keyword like :"limit, skip ,sort ,query,field" mongodb query string criteria ? Can I just :

    /1/classes/:collectionName // to get the collection into model model.find(req.query.where, req.query.fields, req.query.option, function(e,data) //option is pass by query

I don't want to parse the keyword of limit ,skip....

Question 2:

  • How can I get the query criteria in url passing by curl (data-urlencode) , I get nothing in console.log: if(request.method=='GET') { var url_parts = url.parse(request.url,true); console.log(url_parts.query); //console.log('req',request); if(request.body || request.query || request.param) console.log('body',request.body, url_parts.body); //here get nothing console.log('query',request.query, url_parts.query);//here get nothing console.log('param',request.param, url_parts.param);//here get nothing