thenetimp thenetimp - 4 months ago 46
Node.js Question

Prevent Sequelize from outputting SQL to the console on execution of query?

I have a function to retrieve a user's profile.

app.get('/api/user/profile', function (request, response)
// Create the default error container
var error = new Error();

var User = db.User;
where: { emailAddress: request.user.username}
error.status = 500; error.message = "ERROR_INVALID_USER"; error.code = 301;
return next(error);

// Build the profile from the user object
profile = {
"firstName": user.firstName,
"lastName": user.lastName,
"emailAddress": user.emailAddress

When the "find" function is called it displays the select statement on the console where the server was started.

Executing (default): SELECT `id`, `firstName`, `lastName`, `emailAddress`, `password`, `passwordRecoveryToken`, `passwordRecoveryTokenExpire`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`emailAddress` = '' LIMIT 1;

Is there a way to get this not to be display? Some flag that I set in a config file somewhere?


When you create your Sequelize object, pass false to the logging parameter:

var sequelize = new Sequelize('database', 'username', 'password', {

  // disable logging; default: console.log
  logging: false


For more options, check the docs.