I am working with sequelize.js, Where I have a table (say User) with different string fields and a many-to-many relation with another table (say Nationality).
I am trying to insert a new row of User with all the sub-element and the nationality, in one single instruction. Now I am doing like this:
models.Nation.create({codice:"IT",name:"Italia"}).then(function(italy){
models.User.create({username:"local_u",nation:italy}).then(function(){
});
});
If I look at the database, at the newly created User row: the fieldNationId` is not set.
I know I can use the function setNation of sequelize, but I wonder if I can do it within one single User.create.
return models.User.create...Nation.createpromise won't catch errors inUser.create. Bluebird should warn you about this already.