SequelizeJS 软删除在我运行迁移时不起作用

问题描述

有人可以帮我看看我的代码哪里出错了,我尝试按照 this 进行软删除 但相反,它删除了我的整行,我的 deletedAt 不起作用。

这是我的迁移:

module.exports = {
    up: async (queryInterface,Sequelize) => {
        return queryInterface.createTable('pets',{
            ///i've remove some column that doesn't do anything here in my question

            deletedAt:
            {
                type: Sequelize.DATE,allowNull: true,}
        })
    },down: async (queryInterface,Sequelize) => {
        return queryInterface.dropTable('pets');
    }
};

这是我的模型

module.exports = (sequelize,DataTypes) => {
    class pet extends Model {
        static associate(models) {
        }
    };
    pet.init({
        name: {
            type: Sequelize.STRING,allowNull: false,},{
            paranoid: true,sequelize,modelName: 'pet',timestamps: false,});
    pet.associate = function (model) {
        pet.hasOne(model.order,{ foreignKey: "petId",targetKey: "petId" });
        pet.hasOne(model.category,{ as: 'category',foreignKey: 'petId' });
        pet.belongsToMany(model.tag,{
            as: 'tag',through: 'pet_tag',foreignKey: 'petId',otherKey: 'tagId',timestamps: false
        })
    }
    return pet;
};
 
I'm not sure how to check if I'm doing it correctly. 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)