52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
const { DataTypes, Model } = require("sequelize");
|
|
const sequelize = require("../../config/sequelize");
|
|
|
|
class Brand extends Model { }
|
|
|
|
const BrandModel = () => {
|
|
Brand.init(
|
|
{
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
primaryKey: true
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING(200),
|
|
allowNull: true
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true
|
|
}
|
|
},
|
|
{
|
|
sequelize,
|
|
tableName: 'brand',
|
|
timestamps: true,
|
|
indexes: [
|
|
{
|
|
name: "PRIMARY",
|
|
unique: true,
|
|
using: "BTREE",
|
|
fields: [
|
|
{ name: "id" },
|
|
]
|
|
},
|
|
]
|
|
}
|
|
);
|
|
|
|
Brand.prototype.toJSONFor = function () {
|
|
return {
|
|
id: this.id,
|
|
name: this.name,
|
|
description: this.description
|
|
};
|
|
};
|
|
|
|
return Brand;
|
|
};
|
|
|
|
module.exports = BrandModel;
|