rewview
This commit is contained in:
@@ -11,6 +11,7 @@ type FindReviewsOpts = {
|
||||
userId?: string;
|
||||
isApproved?: boolean;
|
||||
orderBy?: string;
|
||||
restId?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
};
|
||||
|
||||
@@ -25,7 +26,7 @@ export class ReviewRepository extends EntityRepository<Review> {
|
||||
* Supports: foodId, userId, isApproved, ordering.
|
||||
*/
|
||||
async findAllPaginated(opts: FindReviewsOpts = {}): Promise<PaginatedResult<Review>> {
|
||||
const { page = 1, limit = 10, foodId, userId, isApproved, orderBy = 'createdAt', order = 'desc' } = opts;
|
||||
const { page = 1, limit = 10, foodId, restId, userId, isApproved, orderBy = 'createdAt', order = 'desc' } = opts;
|
||||
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
@@ -35,6 +36,10 @@ export class ReviewRepository extends EntityRepository<Review> {
|
||||
where.food = { id: foodId };
|
||||
}
|
||||
|
||||
if (restId) {
|
||||
where.food = { restaurant: { id: restId } };
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
where.user = { id: userId };
|
||||
}
|
||||
@@ -63,4 +68,3 @@ export class ReviewRepository extends EntityRepository<Review> {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user