Sequelize bulkCreate() returns NULL value for primary key

前端 未结 7 1660
孤城傲影
孤城傲影 2020-12-15 04:46

I am writing rest using node, sequelize as ORM for mySQL. I am using bulkCreate function to create record in bulk. But in response it is returning null for

7条回答
  •  不思量自难忘°
    2020-12-15 05:17

    The success handler is passed an array of instances, but please notice that these may not completely represent the state of the rows in the DB. This is because MySQL and SQLite do not make it easy to obtain back automatically generated IDs and other default values in a way that can be mapped to multiple records. To obtain Instances for the newly created values, you will need to query for them again. http://docs.sequelizejs.com/en/latest/api/model/#bulkcreaterecords-options-promisearrayinstance

提交回复
热议问题