48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
const { DataTypes, Model } = require("sequelize");
|
|
const sequelize = require("../../config/sequelize");
|
|
|
|
class Packaging extends Model { }
|
|
|
|
const PackagingModel = () => {
|
|
Packaging.init(
|
|
{
|
|
id: {
|
|
autoIncrement: true,
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
primaryKey: true
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: false
|
|
}
|
|
},
|
|
{
|
|
sequelize,
|
|
tableName: 'packaging',
|
|
timestamps: true,
|
|
indexes: [
|
|
{
|
|
name: "PRIMARY",
|
|
unique: true,
|
|
using: "BTREE",
|
|
fields: [
|
|
{ name: "id" },
|
|
]
|
|
},
|
|
]
|
|
}
|
|
);
|
|
|
|
Packaging.prototype.toJSONFor = function () {
|
|
return {
|
|
id: this.id,
|
|
name: this.name
|
|
};
|
|
};
|
|
|
|
return Packaging;
|
|
};
|
|
|
|
module.exports = PackagingModel;
|