Categories
JavaScript Answers

How to see the SQL generated by Node Sequelize.js?

Spread the love

To see the SQL generated by Node Sequelize.js,. we set the logging option.

For instance, we write

const sequelize = new Sequelize("database", "username", "password", {
  logging: console.log,
});

to set the logging property to log with console.log.

We can also write

const sequelize = new Sequelize("database", "username", "password", {
  logging: (str) => {
    // do your own logging
  },
});

to log with our own logging function.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *