feat: add service to fetch all videos from videoService

This commit is contained in:
2026-02-21 20:46:25 +07:00
parent 1038ad068f
commit 46d7dc8da8
4 changed files with 56 additions and 2 deletions

View File

@ -0,0 +1,3 @@
import { prisma } from "../../utils/databases/prisma/connection";
export const videoServiceModel = prisma.videoService;

View File

@ -0,0 +1,39 @@
import { AppError } from "../../../../helpers/error/instances/app";
import { videoServiceModel } from "../../model";
export const getAllVideoServiceWithEpisodeRepository = async (
videoServiceId: string,
) => {
try {
return await videoServiceModel.findMany({
where: {
id: videoServiceId,
videos: {
some: {
episode: {
pictureThumbnail: null,
},
},
},
},
select: {
endpointThumbnail: true,
videos: {
select: {
thumbnailCode: true,
episode: {
select: {
id: true,
},
},
},
},
},
});
} catch (error) {
throw new AppError(
500,
"An error occurred while fetching video services with episodes.",
);
}
};