chore(models): remove unused Product-tmp.js

Leftover scratch file, not registered in src/database/mysql.js and
not referenced anywhere in src/ or scripts/.
This commit is contained in:
2026-04-25 17:22:08 +02:00
parent 137290cf67
commit 7dd2a077e5
-82
View File
@@ -1,82 +0,0 @@
const { DataTypes, Model } = require("sequelize");
const sequelize = require("../../config/sequelize");
const slug = require("slug");
class Product extends Model { }
const ProductModel = () => {
Product.init(
{
id: {
autoIncrement: true,
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true
},
slug: {
type: DataTypes.STRING(255),
allowNull: false
},
title: {
type: DataTypes.STRING(255),
allowNull: false
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
body: {
type: DataTypes.TEXT,
allowNull: false
},
authorId: {
type: DataTypes.STRING(24),
allowNull: true,
references: {
model: 'user',
key: 'id'
}
}
},
{
sequelize,
tableName: 'product',
timestamps: true,
indexes: [
{
name: "PRIMARY",
unique: true,
using: "BTREE",
fields: [
{ name: "id" },
]
},
{
name: "authorId",
using: "BTREE",
fields: [
{ name: "authorId" },
]
},
]
}
);
Product.beforeValidate((product) => {
product.slug = slug(`${product.title}`) + '-' + (Math.random() * Math.pow(36, 6) | 0).toString(36);
});
Product.prototype.toJSONFor = function () {
return {
id: this.id,
slug: this.slug,
title: this.title,
description: this.description,
body: this.body
};
};
return Product;
};
module.exports = ProductModel;