dchester / epilogue

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

Filtering/sorting by association fields #231

Open gibonu opened 6 years ago

gibonu commented 6 years ago

hi is there any way to filter/sort by association fields?

I have a Project model with FK to User as project manager. I have turned on associations in sequelize and epilogue but now I want to be able to select all projects with project manager last name being XXXX.

It is achievable via sequelize so I assume it should be somehow possible with epilogue as well? My resources are defined like that:

var resources = Object.keys(app.get('models')); resources.pop();

resources.forEach(function (resource) { var res = epilogue.resource({ model: app.get('models')[resource], endpoints: ['/' + resource, '/' + resource + '/:id'], associations: true, }); });

where models are sequelize models