我想将记录列表添加到一个表中。但是有时,记录的顺序无法保持。
async function bulkCreate(records) {
for (const data of records) {
await productModel.create(data)
}
}
const products = [
{
productId: 'AA'
},
{
productId: 'BB'
},
{
productId: 'CC'
},
{
productId: 'DD'
},
]
bulkCreate( products )
插入后,有时顺序为DD,AA,BB,CC