biggora / caminte

Cross-db ORM for NodeJS
http://www.camintejs.com/
MIT License
1.08k stars 119 forks source link

Programmatically disconnecting MySQL adapater when "autoReconnect" is enabled #185

Open KingRial opened 6 years ago

KingRial commented 6 years ago

Programmatically disconnecting MySQL adapater when "autoReconnect" is enabled it's impossible. The auto-reconnect feature will re-enable connection.

If you call:

const caminte = require('caminte');
let Schema = caminte.Schema;
let _test = new Schema('mysql', {
      driver: 'mysql',
      host: 127.0.0.1,
      database: 'test',
      pool: false,
      ssl: true,
      autoReconnect: true,
      debug: false
});
...
_test .disconnect();

Caminte is still connected

Using "autoReconnect" set to false seems to solve the situation.

Problaby the "disconnect" method should clear also the intervals set here or here