Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
});
like image 777
minskster Avatar asked Nov 26 '25 06:11

minskster


1 Answers

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

like image 90
Saro Avatar answered Nov 28 '25 20:11

Saro