db/models/club.jsjavascript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sequelize_1 = require("sequelize");
const db_1 = __importDefault(require("../db"));
/**
* @openapi
* components:
* schemas:
* Club:
* type: object
* required:
* - id
* - name
* properties:
* id:
* type: string
* format: uuid
* name:
* type: string
* logoExtension:
* type: string
* example: .png
* creatorId:
* type: string
* format: uuid
* updaterId:
* type: string
* format: uuid
*/
/**
* @typedef Club
* @property {UUID} id
* @property {string} name
* @property {string} [logoExtension]
* @property {UUID} UserId
* @property {UUID} creatorId
* @property {UUID} updaterId
* @memberof module:Models
*/
class Club extends sequelize_1.Model {
}
Club.init({
id: {
type: sequelize_1.DataTypes.UUID,
defaultValue: sequelize_1.DataTypes.UUIDV4,
primaryKey: true,
},
name: {
type: sequelize_1.DataTypes.STRING,
allowNull: false,
},
logoExtension: {
type: sequelize_1.DataTypes.STRING,
allowNull: true,
},
createdAt: sequelize_1.DataTypes.DATE,
updatedAt: sequelize_1.DataTypes.DATE,
deletedAt: sequelize_1.DataTypes.DATE,
}, {
sequelize: db_1.default,
paranoid: true,
hooks: {
afterDestroy: function (instance, _options) {
instance
.getTeams()
.then((teamList) => teamList.forEach((team) => team.destroy()));
},
},
});
exports.default = Club;