Files
teamwallet/myteamwallet_backend/src/files/entities/file.entity.ts
Bastian Wagner 6bea4f766a first commit
2026-07-31 21:02:47 +02:00

31 lines
683 B
TypeScript

import {
Column,
Entity,
PrimaryGeneratedColumn,
AfterLoad,
AfterInsert,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { Allow } from 'class-validator';
import { EntityHelper } from 'src/utils/entity-helper';
import appConfig from '../../config/app.config';
@Entity({ name: 'file' })
export class FileEntity extends EntityHelper {
@ApiProperty({ example: 'cbcfa8b8-3a25-4adb-a9c6-e325f0d0f3ae' })
@PrimaryGeneratedColumn('uuid')
id: string;
@Allow()
@Column()
path: string;
@AfterLoad()
@AfterInsert()
updatePath() {
if (this.path.indexOf('/') === 0) {
this.path = appConfig().backendDomain + this.path;
}
}
}