Files
grow-api/src/salons/entities/salon.entity.ts
T
2026-07-07 19:44:31 +03:30

58 lines
1.2 KiB
TypeScript

import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { City } from '../../provinces/entities/city.entity';
import { Province } from '../../provinces/entities/province.entity';
import { User } from '../../users/entities/user.entity';
@Entity('salons')
export class Salon {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ length: 200 })
name: string;
@Column({ type: 'text', nullable: true })
description: string | null;
@Column({ length: 500 })
address: string;
@Column({ length: 11 })
phone: string;
@Column()
ownerId: string;
@ManyToOne(() => User, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'ownerId' })
owner: User;
@Column({ nullable: true })
provinceId: string | null;
@ManyToOne(() => Province, { onDelete: 'SET NULL', nullable: true })
@JoinColumn({ name: 'provinceId' })
province: Province | null;
@Column({ nullable: true })
cityId: string | null;
@ManyToOne(() => City, { onDelete: 'SET NULL', nullable: true })
@JoinColumn({ name: 'cityId' })
city: City | null;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}