javascript - Express + node.js API filtering -
i developing node api. have endpoint get /messages
this wll homecoming messages. want have pagination on endpoint like
get /messages?filter=my_filter_string&limit=10&offset=10
the filter statement this
{fieldname1}={fieldvalue1}&...{fieldnamen}>{fieldvaluen}. operations can =, > or <. < , > operations number, integers , dates
i using sequelize orm , postgresql db. question how can parse my_filter_statement , convert search criteria object sequelize. if phone call api like
get /messages?filter="id=10&contentlength>20"&limit=10&offset=10
it not working
can have, example:
get /messages?greater=1&less=5&limit=10&offset=10
and in node:
var url = require('url'); var url_parts = url.parse(request.url, true); var query = url_parts.query;
and match query parameters, such greater/less (which shortened "gt" , "lt"), symbols need in statement?
javascript node.js postgresql rest express
No comments:
Post a Comment