如何在sequelize.js中隐藏包含的模型?
如何隐藏包含的模型?我用谷歌搜索它,并尝试通过:{attributes:[]},但得到错误如何在sequelize.js中隐藏包含的模型?,sequelize.js,Sequelize.js,如何隐藏包含的模型?我用谷歌搜索它,并尝试通过:{attributes:[]},但得到错误TypeError:无法读取未定义的属性“getTableName” 我有虚拟属性封面 ... covers: { type: DataTypes.VIRTUAL, get () { const result = [] const covers = ['coverOne', 'coverTwo', 'coverThree', 'coverFou
TypeError:无法读取未定义的属性“getTableName”
我有虚拟属性封面
...
covers: {
type: DataTypes.VIRTUAL,
get () {
const result = []
const covers = ['coverOne', 'coverTwo', 'coverThree', 'coverFour']
for (let cover of covers) {
if (isNotEmptyObject(this[cover].dataValues)) {
result.push(this[cover])
}
}
return result
}
}
...
volumes.belongsTo(models.externalResources, {
foreignKey: 'imageOne',
as: 'coverOne'
})
volumes.belongsTo(models.externalResources, {
foreignKey: 'imageTwo',
as: 'coverTwo'
})
volumes.belongsTo(models.externalResources, {
foreignKey: 'imageThree',
as: 'coverThree'
})
volumes.belongsTo(models.externalResources, {
foreignKey: 'imageFour',
as: 'coverFour'
})
我只想显示covers属性,并隐藏coverOne/Two/Three/Four。
提前Thx在返回结果之前,只需使用lodash省略这些项即可
在返回结果之前,只需使用lodash忽略这些项
求你了,别这样,求你了,别这样。
const result = { ...omit(covers, ['coverOne', 'coverTwo', 'coverThree', 'coverFour']) }