Open hbzhang opened 8 years ago
@hbzhang I think this would work:
api.afterGetPeople(execPeopleQuery);
function execPeopleQuery(req, res, model) {
res.send({
id: model.get('id'),
name: model.get('name')
});
}
you would have to use the afterGetPeople hook in this case
not an ideal solution though. It might be better to add support for this using query parameters, something like /people/123?include=id,name
This could be useful to process every model on every route. Imagine everytime all you want is to send the id and name, and hide every other fields.
Maybe another hook to process models before they are sent would be a nice addition. What do you think?
Thanks for this good tool. Wonder how to only fetch certain columns? I have tried the following:
api.beforeGetPeople(execPeopleQuery);
function execPeopleQuery(req, res, model) { model.fetch({columns: ['id','name']}); }
But the results still returns all the columns.
Thanks!