baugarten / node-restful

A library for quickly providing a REST API with express or connect
http://www.baugarten.me/node-restful/
1.31k stars 249 forks source link

Separate query builder from node-restful #76

Open sanderhouttekier opened 9 years ago

sanderhouttekier commented 9 years ago

Current version has the query building and handling of all filterables integrated in the model module. In your rewrite it would be useful to separate those things out of there.

usecase: user has a custom like: users/<id>/log doesn't matter what log is, but it's not a detail route, it is another list route. it would be very useful for this list route to be able to use the same filtering like ?limit=5 or ?status__ne=error .... so If you separate that out in a module of it's own, either another npm module or just a separate module within node-restful. I could see it being reused to build a filterable query which automatically uses the req params to search in the db.

This is me thinking out loud while I was sort of hacking away at a querybuilder suddenly realising you already do all of that within your node-restful module...

sanderhouttekier commented 9 years ago

While investigating and building my own version of the querybuilder for use outside node-restful, i got in touch with the developer of fghibellini/mongoose-ref-query ... maybe an idea to use this one in your rewrite. ... no need to build something yourself if it already exists :)...

baugarten commented 9 years ago

Sounds interesting. I was going to look into factoring it out, but if it already exists, then that's even better :) Thanks for the heads up :beers: