47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { AppError } from "../../../../helpers/error/instances/app";
|
|
import { prisma } from "../../../../utils/databases/prisma/connection";
|
|
|
|
export const findAllActiveHeroBannerRepository = async () => {
|
|
try {
|
|
return await prisma.heroBanner.findMany({
|
|
where: {
|
|
startDate: {
|
|
lte: new Date(),
|
|
},
|
|
endDate: {
|
|
gte: new Date(),
|
|
},
|
|
},
|
|
orderBy: [
|
|
{
|
|
orderPriority: "asc",
|
|
},
|
|
{
|
|
startDate: "asc",
|
|
},
|
|
],
|
|
select: {
|
|
orderPriority: true,
|
|
imageUrl: true,
|
|
media: {
|
|
select: {
|
|
id: true,
|
|
title: true,
|
|
slug: true,
|
|
pictureLarge: true,
|
|
synopsis: true,
|
|
genres: {
|
|
select: {
|
|
slug: true,
|
|
name: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
} catch (error) {
|
|
throw new AppError(500, "Failed to fetch active hero banners", error);
|
|
}
|
|
};
|