How does sequelize give one-to-many associated tables create records at the same time

  1. problem description: there are two tables with one to many. The json data received from the front end already contains the records of the main table and the child table. How can create be recorded as the best solution?

2. Table structure such as:

[user]:name,age;
[record]:userid,recordinfo;

3. Json: received from the front end

{"user":{name:"",
         age:20,
         record:[
             {recordinfo:"1925"},
             {recordinfo:"1945"},
             {recordinfo:"1949"}
         ]}

4. How to use sequelize to create, the best?

Jun.23,2021
Menu