Support nested includes #10

Open
opened 2016-07-13 06:00:39 +00:00 by casalot · 5 comments
casalot commented 2016-07-13 06:00:39 +00:00 (Migrated from github.com)

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.

I have the following associations defined: ``` javascript 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.
mdibaiee commented 2016-07-13 06:03:03 +00:00 (Migrated from github.com)

The standard way to represent arrays in HTTP GET parameters is include[]=Assessment&include[]=Organisation, may you try that?

The standard way to represent arrays in HTTP GET parameters is `include[]=Assessment&include[]=Organisation`, may you try that?
casalot commented 2016-07-13 06:10:14 +00:00 (Migrated from github.com)

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?

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?
mdibaiee commented 2016-07-13 06:22:03 +00:00 (Migrated from github.com)

Great!

Um, nested associations are not supported at the moment. You can create a pull-request if you want.

Great! Um, nested associations are not supported at the moment. You can create a pull-request if you want.
casalot commented 2016-07-13 07:34:00 +00:00 (Migrated from github.com)

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!

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!
mdibaiee commented 2016-07-13 07:34:38 +00:00 (Migrated from github.com)

Alright, that's fine. Thank you for reporting and following up with the issues.

Alright, that's fine. Thank you for reporting and following up with the issues.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: thereadme/hapi-sequelize-crud#10
No description provided.