chore: add new route to get users of services

This commit is contained in:
mahyargdz
2025-03-04 11:38:17 +03:30
parent bf991914e4
commit 98734aee9d
4 changed files with 39 additions and 2 deletions
@@ -1,7 +1,8 @@
// eslint-disable-next-line import/no-named-as-default
import Decimal from "decimal.js";
import { Column, Entity, Index, ManyToOne } from "typeorm";
import { Column, Entity, Index, ManyToOne, OneToMany } from "typeorm";
import { UserSubscription } from "./user-subscription.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
import { DanakService } from "../../danak-services/entities/danak-service.entity";
@@ -25,6 +26,9 @@ export class SubscriptionPlan extends BaseEntity {
@ManyToOne(() => DanakService, (danakService) => danakService.subscriptionPlans, { nullable: false, onDelete: "CASCADE" })
service: DanakService;
@OneToMany(() => UserSubscription, (userSubscription) => userSubscription.plan)
userSubscriptions: UserSubscription[];
// @ManyToMany(() => Discount, (discount) => discount.subscriptionPlans)
// discounts: Discount[];
}
@@ -10,7 +10,7 @@ export class UserSubscription extends BaseEntity {
@ManyToOne(() => User, (user) => user.subscriptions, { nullable: false, onDelete: "CASCADE" })
user: User;
@ManyToOne(() => SubscriptionPlan, { nullable: false, onDelete: "CASCADE" })
@ManyToOne(() => SubscriptionPlan, (plan) => plan.userSubscriptions, { nullable: false, onDelete: "CASCADE" })
plan: SubscriptionPlan;
@Column({ type: "timestamp", nullable: false })