Closed felix-cao closed 2 months ago
使用 defaultScope
defaultScope
const User = sequelize.define( "User", { firstName: types.string, lastName: types.string, email: types.string, password: types.string }, { defaultScope: { attributes: { exclude: ["password"] } } } ); User.findByPk(user_id) // No password attribute User.findByPk(user_id, {attributes: ['password']}) //
数据脱敏data sensitive
使用
defaultScope