W
W
webe2021-08-13 02:18:50
Node.js
webe, 2021-08-13 02:18:50

How to properly reconnect in sequalize?

help plz
Let's say I connect to the database and the server is unavailable.
How to organize a reconnect? Is there some kind of built-in API?

const sequelize = new Sequelize('Education', 'root','', {
 host: '127.0.0.1',
 dialect: 'mysql'
 } );

  //test db 
 sequelize
.authenticate()
.then(() => {
  console.log('Connection has been established successfully.');
})
 .catch(err => {
 console.error('Unable to connect to the database:', err);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kulakov, 2021-08-13
@ivankprod

Well wrap in while until the connection is established)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question