Files
AnimeTV-Backend/src/modules/heroBanner/repositories/GET/findAllActiveHeroBanner.repository.ts
Rafi Arrafif 01ad69a4b0
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 1m48s
👔 feat: add banner priority ordering logic
2026-03-02 23:07:30 +07:00

28 lines
636 B
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",
},
],
});
} catch (error) {
throw new AppError(500, "Failed to fetch active hero banners", error);
}
};