Converted models to TypeORM models

This commit is contained in:
Alexis
2021-07-31 12:38:04 +02:00
parent 477dc14e63
commit dce8bf95d6
12 changed files with 113 additions and 450 deletions

View File

@@ -1,54 +1,12 @@
import { DataTypes, Model, Optional } from "sequelize";
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
interface RoleAttributes {
id: number
uuid: string
name: string
description: string
}
interface RoleCreationAttributes extends Optional<RoleAttributes, 'id'> { }
export class Role extends Model<RoleAttributes, RoleCreationAttributes> implements RoleAttributes {
public readonly id!: number
@Entity()
export class Role {
@PrimaryGeneratedColumn('uuid')
public readonly uuid!: string
@Column()
public name!: string
@Column()
public description!: string
public readonly createdAt!: Date;
public readonly updatedAt!: Date;
}
export default () => {
Role.init(
{
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true
},
uuid: {
type: DataTypes.UUID,
allowNull: false,
unique: true,
defaultValue: DataTypes.UUIDV4
},
name: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
description: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
},
{
tableName: 'au_roles',
sequelize: AuracleDatabaseDriver,
}
)
}