44 lines
1.4 KiB
TypeScript
Executable File
44 lines
1.4 KiB
TypeScript
Executable File
import { Column, DeleteDateColumn, Entity, JoinTable, ManyToMany, ManyToOne } from "typeorm";
|
|
|
|
import { SubscriptionPlan } from "./subscription.entity";
|
|
import { BaseEntity } from "../../../common/entities/base.entity";
|
|
import { User } from "../../users/entities/user.entity";
|
|
import { SubscriptionStatus } from "../enums/subscription-status.enum";
|
|
|
|
@Entity()
|
|
export class UserSubscription extends BaseEntity {
|
|
@ManyToOne(() => User, (user) => user.subscriptions, { nullable: false, onDelete: "CASCADE" })
|
|
user: User;
|
|
|
|
@ManyToOne(() => SubscriptionPlan, (plan) => plan.userSubscriptions, { nullable: false, onDelete: "CASCADE" })
|
|
plan: SubscriptionPlan;
|
|
|
|
@Column({ type: "timestamptz", nullable: false })
|
|
startDate: Date;
|
|
|
|
@Column({ type: "timestamptz", nullable: false })
|
|
endDate: Date;
|
|
|
|
@Column({ type: "varchar", length: 250, nullable: false })
|
|
businessName: string;
|
|
|
|
@Column({ type: "varchar", length: 50, nullable: true })
|
|
businessPhone: string | null;
|
|
|
|
@Column({ type: "text", nullable: true })
|
|
description: string | null;
|
|
|
|
@Column({ type: "varchar", length: 250, unique: true, nullable: true })
|
|
slug: string;
|
|
|
|
@Column({ type: "enum", enum: SubscriptionStatus, default: SubscriptionStatus.INACTIVE })
|
|
status: SubscriptionStatus;
|
|
|
|
@ManyToMany(() => User)
|
|
@JoinTable()
|
|
staff: User[];
|
|
|
|
@DeleteDateColumn({ type: 'timestamptz', nullable: true })
|
|
deletedAt?: Date;
|
|
}
|