dchester / epilogue

Create flexible REST endpoints and controllers from Sequelize models in your Express app
846 stars 116 forks source link

Action-contextual config #114

Open xizhao opened 8 years ago

xizhao commented 8 years ago

Is there a way we can specify the general config i.e. include or attributes for the specific CRUD action? Similar to configuring search.

example

resource({
  model: somemodel,
  include: [OtherModel],
  read: {
    include: [AndThisModel],
    excludedAttributes: ['andthisfield', 'justforread']
  }
})
mbroadst commented 8 years ago

Yes, you can use milestones to specify e.g. the attributes or include for a controller:

myResource.read.fetch.before(function(req, res, context) {
   context.attributes = ['some', 'list', 'of', attributes'];
   context.include = [ AndThisModel ];
   return context.continue;
});
xizhao commented 8 years ago

Thank you! can we make this more declarative in the config rather than having to set up middleware functions?