Categories
JavaScript Answers

How to make Sequelize table without column ‘id’ with Node.js?

Spread the love

To make Sequelize table without column ‘id’ with Node.js, we call the removeAttribute method.

For instance, we write

AcademyModule = sequelize.define(
  "academy_module",
  {
    academy_id: DataTypes.INTEGER,
    module_id: DataTypes.INTEGER,
    module_module_type_id: DataTypes.INTEGER,
    sort_number: DataTypes.INTEGER,
    requirements_id: DataTypes.INTEGER,
  },
  {
    freezeTableName: true,
  }
);
AcademyModule.removeAttribute("id");

to define the AcademyModule model with define.

We map it to the academy_module table in the database.

We call removeAttribute to remove the id column.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *