我尝试获取deleted_at 列中为空的所有事件用户。
Model.findAll({
raw: true,
where: {
user_id: user_id,
status: true,
deleted_at: {
$ne: null
}
},
attributes: ['name']
}).map(el => el.get('name'));
这总是返回空值,在我的数据库中,我有一行 deleted_at: null
。这样做的正确方法是什么?
最佳答案
如果您将 paranoid: true
添加到您的模型中,Sequelize 将自动包含一个 SQL 查询“where deleted_at is not null”。您将其添加到模型中并删除 Controller 中额外的 where 配置。
关于javascript - 使用 Not Null 将 findAll 序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64061362/