U
U
urajo2020-04-14 02:55:10
Node.js
urajo, 2020-04-14 02:55:10

How to disable createdAt in many-to-many relationship?

How to disable createdAt when generating tables, I registered timestamps in the model, but it is in the linking tables that the add and update columns are still created.

Sequelize = require('sequelize'),
        sequelize = new Sequelize('directory','direc','9696Gory!',{
            dialect: 'mysql',
            host: '45.84.226.226'
        }),
        left = sequelize.define('left',{
            id:{
                type: Sequelize.INTEGER,
                autoIncrement: true,
                primaryKey: true,
                allowNull: false
            },
            name:{
                type: Sequelize.STRING,
                allowNull: false
            }
        },{
            timestamps: false,
            freezeTableName: true
        }),
        main = sequelize.define('main',{
            id:{
                type: Sequelize.INTEGER,
                autoIncrement: true,
                primaryKey: true,
                allowNull: false
            },
            name:{
                type: Sequelize.STRING,
                allowNull: false
            }
        },{
            timestamps: false,
            freezeTableName: true
        }),
        data = sequelize.define('data',{
            id:{
                type: Sequelize.INTEGER,
                autoIncrement: true,
                primaryKey: true,
                allowNull: false
            },
            function:{
                type: Sequelize.STRING,
                allowNull: false
            },
            name:{
                type: Sequelize.STRING,
                allowNull: false
            },
            cabinet:{
                type: Sequelize.STRING,
                allowNull: false
            },
            phone:{
                type: Sequelize.STRING,
                allowNull: false
            }
        },{
            timestamps: false,
            freezeTableName: true
        }),
        m_l = sequelize.define('m_l',{
            id:{
                type: Sequelize.INTEGER,
                autoIncrement: true,
                primaryKey: true,
                allowNull: false
            }
        },{
            timestemps: false,
            freezeTableName: true
        }),
        l_d = sequelize.define('l_d',{
            id:{
                type: Sequelize.INTEGER,
                autoIncrement: true,
                primaryKey: true,
                allowNull: false
            }
        },{
            timestemps: false,
            freezeTableName: true
        });

    main.belongsToMany(left,{through: m_l});
    left.belongsToMany(main,{through: m_l});

    left.belongsToMany(data,{through: l_d});
    data.belongsToMany(left,{through: l_d});
sequelize.sync({force:true}).then(()=>{
  console.log('true');
}).catch(err=>console.log(err));

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question