Skip to content

Conversation

morenoh149
Copy link
Contributor

  • use Object.values to get a more meaningful model var and associate it if it has an associate field.

* use Object.values to get a more meaningful `model` var and associate it if it has an associate field.
@Sharlaan
Copy link

Sharlaan commented Mar 9, 2019

Another variant, bit more "functional" :

  Object.values(models)
    .filter(model => typeof model.associate === 'function')
    .forEach(model => model.associate(models));

@morenoh149
Copy link
Contributor Author

morenoh149 commented Mar 9, 2019

@Sharlaan I also considered

 Object.values(models)
    .filter(model => model.associate)
    .forEach(model => model.associate(models));

and

 Object.values(models).forEach(model => model.associate && model.associate(models));

but I preferred my proposal as most understandable.

@rwieruch
Copy link
Member

Thanks for the input! I will take this into account once I write a new version for the tutorial 🚀 Given that it will take some time, please leave your suggestions here on how to make it more idiomatic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants