Open morenoh149 opened 5 years ago
Another variant, bit more "functional" :
Object.values(models)
.filter(model => typeof model.associate === 'function')
.forEach(model => model.associate(models));
@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.
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!
model
var and associate it if it has an associate field.