Initial commit

This commit is contained in:
Lorenzo Sanesi
2026-03-26 22:46:03 +01:00
commit 18e0e04700
80 changed files with 13114 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
const { DataTypes } = require('sequelize');
module.exports = (sequelize) => {
const Friendship = sequelize.define('Friendship', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
}
// Foreign keys 'user1Id' and 'user2Id' are added via associations
}, {
timestamps: false,
tableName: 'friendships',
hooks: {
// Ensure user1Id is always less than user2Id to guarantee
// a unique friendship pair regardless of creation order.
beforeValidate: (friendship) => {
if (friendship.user1Id > friendship.user2Id) {
[friendship.user1Id, friendship.user2Id] = [friendship.user2Id, friendship.user1Id];
}
}
}
});
return Friendship;
};