批量生成后,Sequelize不会关闭

时间:2018-05-16 13:05:26

标签: node.js sequelize.js

我刚刚开始使用Sequelize写入MSSQL数据库 - 一切正常,但我的节点程序永远不会完成并返回到终端。代码如下所示:

const Sequelize = require('sequelize');
var sequelize = new Sequelize(...);
const JournalLine = sequelize.define('journalLine', {...});
JournalLine.sync().then(() => {
   JournalLine.bulkCreate([...])
});

为了结束程序,我需要关闭一些东西吗?

1 个答案:

答案 0 :(得分:0)

您没有提供callback功能或使用Promise,以下工作

const Sequelize = require('sequelize');
var sequelize = new Sequelize(...);
const JournalLine = sequelize.define('journalLine', {...});
JournalLine.sync().then(() => {
   return JournalLine.bulkCreate([...]).then( result => {
     console.log('done');
     return result;
   })
});