sequelize.js - sequelize oneToMany create nested associations -
is there way have sequelize create nested associations via single create call? example if have model data
hasmany
of model user
, , each user hasmany
of model permission
. there way call data.create
data
containing user
, permission
, , sequelize create nested associations?
the thing i've found on sequelize docs using include
pull in nested associations on find
call, or calling setter after data.create
, e.g. data.setusers(...)
.
as far know, can done if records new. in case means having new data
new user
s have new permission
s. otherwise, you'll have "manual" way.
for more info, see documentation here: http://docs.sequelizejs.com/en/latest/docs/associations/#creating-with-associations
Comments
Post a Comment