How can I see the SQL generated by Sequelize.js?
As stated in the log Error: Please note that find* was refactored and uses only one options object from now on.
. For the latest sequelize version (4) if you want to have the result for only one command:
User.findAll({where: {...}, logging: console.log})
You can pass a logging option when initializing sequelize, which can either be a function or console.log
var sequelize = new Sequelize('database', 'username', 'password', {
logging: console.log
logging: function (str) {
// do your own logging
}
});
You can also pass a logging option to .sync if you only want to view the table creation queries
sequelize.sync({ logging: console.log })
If you want to look at the sequelize for one command you can listen to it and attach a function to the print the sql.
Check out this example:
User.find(1).on('sql', console.log).then(function(user) {
// do whatever you want with the user here