hapi-sequelize-crud
hapi-sequelize-crud copied to clipboard
Support nested includes
I have the following associations defined:
module.exports = ({
Assessment, Event, Organisation
}) => {
Event.hasMany(Assessment, {foreignKey:'eventId'});
Event.belongsTo(Organisation, {foreignKey:'organisationId'});
}
Calling http://localhost:3030/api/seq/events?include=Assessment
or http://localhost:3030/api/seq/events?include=Organisation
produces the response, including the associated entity. But http://localhost:3030/api/seq/events?include=[Assessment,Organisation]
includes none of the associated entities.
The standard way to represent arrays in HTTP GET parameters is include[]=Assessment&include[]=Organisation
, may you try that?
Perfect! That works, thanks.
One more question. If I had nested associations, e.g. Event
hasMany Assessments
hasMany Questions
, how would the GET request parameters look?
Great!
Um, nested associations are not supported at the moment. You can create a pull-request if you want.
Uhm, I had a look at the code, and don't think I'll be able to get this done ... Will leave it as a feature request for you, whenever you get the time.
Thanks for sorting out the other issues so quickly!
Alright, that's fine. Thank you for reporting and following up with the issues.