Mise à jour des models mysql

This commit is contained in:
Rampeur
2025-08-15 15:54:13 +02:00
parent 8a011af73a
commit bd3d1ade49
14 changed files with 633 additions and 156 deletions
+63
View File
@@ -0,0 +1,63 @@
const { DataTypes, Model } = require("sequelize");
const sequelize = require("../../config/sequelize");
class Follower extends Model { }
const FollowerModel = () => {
Follower.init(
{
userId: {
type: DataTypes.STRING(24),
allowNull: false,
primaryKey: true,
references: {
model: 'user',
key: 'id'
}
},
followerId: {
type: DataTypes.STRING(24),
allowNull: false,
primaryKey: true,
references: {
model: 'user',
key: 'id'
}
}
},
{
sequelize,
tableName: 'follower',
timestamps: false,
indexes: [
{
name: "PRIMARY",
unique: true,
using: "BTREE",
fields: [
{ name: "userId" },
{ name: "followerId" },
]
},
{
name: "followerId",
using: "BTREE",
fields: [
{ name: "followerId" },
]
},
]
}
);
Follower.prototype.toJSONFor = function () {
return {
userId: this.userId,
followerId: this.followerId
};
};
return Follower;
};
module.exports = FollowerModel;