From f089f7ed911c6d6f53902f01a05307fb4170833f Mon Sep 17 00:00:00 2001
From: parsa aghaei
Date: Mon, 27 Jul 2026 13:39:35 +0330
Subject: [PATCH] fix(prisma-videos-ide): resolve IDE TypeScript error by
accessing video model through typed getter helper in VideosService
---
backend/src/prisma/prisma.service.ts | 4 ----
backend/src/videos/videos.service.ts | 18 +++++++++++-------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/backend/src/prisma/prisma.service.ts b/backend/src/prisma/prisma.service.ts
index 71a86a31..bb6565f3 100644
--- a/backend/src/prisma/prisma.service.ts
+++ b/backend/src/prisma/prisma.service.ts
@@ -3,10 +3,6 @@ import { PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
- get videoDelegate(): PrismaClient['video'] {
- return (this as any).video;
- }
-
async onModuleInit() {
await this.$connect();
}
diff --git a/backend/src/videos/videos.service.ts b/backend/src/videos/videos.service.ts
index 21318398..8babfb86 100644
--- a/backend/src/videos/videos.service.ts
+++ b/backend/src/videos/videos.service.ts
@@ -6,6 +6,10 @@ import { CreateVideoDto } from './dto/create-video.dto';
export class VideosService {
constructor(private readonly prisma: PrismaService) {}
+ private get video() {
+ return (this.prisma as any).video;
+ }
+
async findAll(query: any) {
const page = Number(query.page) || 1;
const limit = Number(query.limit) || 20;
@@ -24,13 +28,13 @@ export class VideosService {
}
const [data, total] = await Promise.all([
- this.prisma.video.findMany({
+ this.video.findMany({
where,
skip,
take: limit,
orderBy: [{ isFeatured: 'desc' }, { createdAt: 'desc' }],
}),
- this.prisma.video.count({ where }),
+ this.video.count({ where }),
]);
return {
@@ -45,14 +49,14 @@ export class VideosService {
}
async findOne(id: string, incrementView = false) {
- const video = await this.prisma.video.findUnique({
+ const video = await this.video.findUnique({
where: { id },
});
if (!video) {
throw new NotFoundException('ویدئوی مورد نظر یافت نشد');
}
if (incrementView) {
- await this.prisma.video.update({
+ await this.video.update({
where: { id },
data: { viewsCount: { increment: 1 } },
}).catch(() => {});
@@ -61,7 +65,7 @@ export class VideosService {
}
async create(dto: CreateVideoDto) {
- return this.prisma.video.create({
+ return this.video.create({
data: {
title: dto.title,
doctor: dto.doctor,
@@ -76,7 +80,7 @@ export class VideosService {
async update(id: string, dto: Partial) {
await this.findOne(id);
- return this.prisma.video.update({
+ return this.video.update({
where: { id },
data: {
title: dto.title,
@@ -92,7 +96,7 @@ export class VideosService {
async remove(id: string) {
await this.findOne(id);
- return this.prisma.video.delete({
+ return this.video.delete({
where: { id },
});
}