✨ feat: add get all media endpoint
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 56s
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 56s
This commit is contained in:
17
src/modules/media/repositories/GET/getAllMedia.repository.ts
Normal file
17
src/modules/media/repositories/GET/getAllMedia.repository.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { AppError } from "../../../../helpers/error/instances/app";
|
||||
import { mediaModel } from "../../model";
|
||||
|
||||
export const getAllMediaRepository = async (page: number) => {
|
||||
try {
|
||||
const limit = 10;
|
||||
return await mediaModel.findMany({
|
||||
take: limit,
|
||||
skip: (page - 1) * limit,
|
||||
where: {
|
||||
deletedAt: null,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
throw new AppError(500, "Failed to get all media from repository", error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user