我具有检索用户个人资料的功能。
app.get('/api/user/profile', function (request, response) { // Create the default error container var error = new Error(); var User = db.User; User.find({ where: { emailAddress: request.user.username} }).then(function(user) { if(!user) { 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 } response.status(200).send(profile); }); });
调用“查找”功能时,它将在启动服务器的控制台上显示select语句。
Executing (default): SELECT `id`, `firstName`, `lastName`, `emailAddress`, `password`, `passwordRecoveryToken`, `passwordRecoveryTokenExpire`, `createdAt`, `updatedAt` FROM `Users` AS `User` WHERE `User`.`emailAddress` = 'johndoe@doe.com' LIMIT 1;
有没有办法使它不显示?我在某个地方的配置文件中设置的一些标志?
创建Sequelize对象时,传递false给logging参数:
false
logging
var sequelize = new Sequelize('database', 'username', 'password', { // disable logging; default: console.log logging: false });
有关更多选项,请检查docs。