chore: first
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { EntityRepository } from "@mikro-orm/postgresql";
|
||||
|
||||
import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
||||
import { SearchNotificationQueryDto } from "../DTO/search-notification-query.dto";
|
||||
import { Notification } from "../entities/notification.entity";
|
||||
|
||||
export class NotificationRepository extends EntityRepository<Notification> {
|
||||
async getAllNotifications(queryDto: SearchNotificationQueryDto, recipientId: string) {
|
||||
const { skip, limit } = PaginationUtils(queryDto);
|
||||
|
||||
const qb = this.qb("notification").where({ recipientId });
|
||||
|
||||
if (queryDto.isRead !== undefined) {
|
||||
qb.andWhere({ isRead: queryDto.isRead === 1 });
|
||||
}
|
||||
|
||||
return qb.orderBy({ createdAt: "DESC" }).offset(skip).limit(limit).getResultAndCount();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user