I'm trying to save sequelize models with their associations. All the associations are one to one. Retrieving models with associations from the database works just fine but inserting them is another matter and the documentation is just making me more confused.
Here's my insert method:
models
.radcheck
.create(user, {
include: [{model: models.skraningar}, {model: models.radusergroup}, {model: models.radippool}]
})
.then(success, error);
I've seen so many ways to do this both in the documentation and here on stackoverflow and none of them make sense to me so far. Anyone care to clear things up for me?
I always save a model with association by it's foreign key
e.g
models.user.create({ name : 'test', usergroup_id : 1 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With