Subd/server/models/role.model.ts

28 lines
564 B
TypeScript
Raw Normal View History

2024-04-23 12:08:46 +04:00
import { Table, Column, Model, DataType, Length, HasMany } from "sequelize-typescript";
import User from "./user.model";
@Table({
timestamps: false,
tableName: "roles",
modelName: "Role"
})
export default class Role extends Model {
@Column({
primaryKey: true,
autoIncrement: true,
type: DataType.INTEGER
})
declare id: number;
@Length({ min: 1, max: 20 })
@Column({
allowNull: false,
defaultValue: "Unknown",
type: DataType.STRING
})
declare name: string;
@HasMany(() => User, "role_id")
declare users: User[];
}