paranoid是开启的。id是1的已经destroy软删除了,现在想恢复。首先用下面的语句查出来,再执行restore.
const admin = await ctx.model.Admin.findOne({
where: {
id:2,
deletedAt: {
$ne: null
}
}
});
最后执行的sql是
SELECT `id`, `userName`, `password`, `email`, `createdAt`, `updatedAt`, `deletedAt` FROM `Admins` AS `Admin` WHERE (`Admin`.`deletedAt` IS NULL AND (`Admin`.`id` = 2 AND `Admin`.`deletedAt` = '2020-03-05 00:00:00'));
发现根本查不出来。一直有一个deletedAt是null的条件,而且$ne也变成了等于一个时间戳。
什么鬼?
没有仔细看文档。。。
If true, only non-deleted records will be returned. If false, both deleted and non-deleted records will be returned. Only applies if
options.paranoid
is true for the model.