Fix(crud) include param lookup now works w/plurals #26

Merged
joeybaker merged 3 commits from fix-include into master 2016-10-26 18:42:15 +00:00

3 Commits

Author SHA1 Message Date
Joey Baker
bcb7861061 Fix(crud) include param lookup now works w/plurals
Previously, {one,many}-to-many relationships with models would result in
`associationNames` that were plural. e.g. `Team` might have many
players and one location. The validation was expecting to see the plural
`Players` and the singular `Location` but Sequelize is expecting the
singular `Player` (`Location` worked fine). This meant that include
lookups would silently fail. This fixes the problem in a backward-
compatible way.

It continues to allow `include=Location` (capitalized) for backward-
compatibility. And now allows and actually does the lookup for
`include=players`, `include=player`, `include=Player`, `include=Players`
lookup relationships.
2016-10-26 11:19:36 -07:00
Joey Baker
07176018b7 Fix(crud) include param can be a string or array 2016-10-26 10:59:02 -07:00
Joey Baker
83eadf0929 Fix: don't build CRUD routes until ready
Previously, we were building the crud routes before we had run through
the association logic. This meant that routes could get created without
a complete list of associations available to it. This is slightly less
performant b/c we need to run through two loops, but ensures that the
full association data is available to all routes.
2016-10-26 10:57:54 -07:00