4

Good afternoon everyone. I am developing a node.js/express system using sequelize.js (postgresql).

My problem is: I need to store the raw queries generated by sequelize in a log history, but I can't find a function that returns the generated query. Does anyone know if sequelize provides a function that returns the generated SQL query, or if there's any other way to achieve this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Diego Moreira
  • 617
  • 2
  • 6
  • 7

1 Answers1

9

Your best bet is to use Sequelize's built-in logging functionality.

var sequelize = new Sequelize('db', 'username', 'pwd', {

  // you can either write to console
  logging: console.log

  // or write your own custom logging function
  logging: function (str) {
    // do stuff with the sql str
  }
});
Yuri Zarubin
  • 11,439
  • 4
  • 30
  • 33