3

以下脚本执行后未完成。DB 得到了记录,但脚本仍在继续工作。为什么?

var Sequelize = require("sequelize");
var sequelize = new Sequelize('database_name', 'mylogin', 'mypassword', {
                host: 'db_host',
                port: 5432,
                dialect: 'postgres',
                protocol: 'postgres',
                logging: true,
                omitNull: true,
});

var iteration = sequelize.define('iteration', {
               id: { type: Sequelize.BIGINT ,
        primaryKey: true,
        autoIncrement: true,
        unique: true},
    imported: { type: Sequelize.DATE, defaultValue: Sequelize.NOW },
    }, {
tableName: 'iterations'}
);

iteration.create({ imported: Sequelize.NOW}).success(function(iter) {
console.log(iter);
});
4

1 回答 1

5

您必须调用 sequelize.close() 才能停止执行。只要连接打开,执行就不会停止。

于 2015-07-06T12:36:09.337 回答