我有一个名为person
的表,我希望将列排除为默认列,
const Person = sequelize.define('person',{
secretColumn: Sequelize.STRING,
//... and other columns
});
我看到Sequelize中有一个名为Scope
的功能:
http://docs.sequelizejs.com/manual/tutorial/scopes.html
我试图像这样排除;
const Person = sequelize.define('person',{
secretColumn: Sequelize.STRING,
//... and other columns
}, {
defaultScope: {
exclude: ['secretColumn']
}
});
但这确实有效。是否还有其他方法可以在默认情况下排除列?
答案 0 :(得分:11)
我把它搞得一团糟。 exclude
需要attributes
部分:
const Person = sequelize.define('person',{
secretColumn: Sequelize.STRING,
//... and other columns
}, {
defaultScope: {
attributes: { exclude: ['secretColumn'] }
}
});