minskster
minskster

Reputation: 532

Node.js, sequelize. The script execution is not stopped

The following script is not finished after the execution. DB got the record but the script is continue working. Why?

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);
});

Upvotes: 3

Views: 1004

Answers (1)

Saro
Saro

Reputation: 870

You must call sequelize.close() in order to stop the execution. As long as the connection is open the execution does not stop.

Upvotes: 5

Related Questions