Ajout et mise à jour de models mysql

This commit is contained in:
Rampeur
2025-08-29 16:08:53 +02:00
parent b1513dccdd
commit 6510c55458
10 changed files with 566 additions and 20 deletions
+47
View File
@@ -0,0 +1,47 @@
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;