我知道options.attributes你列出了你想要选择的属性,但有没有办法只排除一个字段?
到目前为止,我已经解决了
User
.findAll({order: [['id','DESC']]})
.then(function(users) {
users = users.filter(function(user){
delete user.dataValues.password;
return user;
});
return reply( ReplyUtil.ok(users) );
})
.catch(function(err){
return reply( ReplyUtil.badImplementation(err) );
});
Run Code Online (Sandbox Code Playgroud)
我不明白为什么你应该使用user.dataValues.password
if not delete 不起作用,而不是简单地user.password
如果我像这样调试console.log('pass: ', user.password)我可以看到密码。