server: refactor pagination

* fix transaction usgae in repos
* other bug fixes
This commit is contained in:
Philipinho
2024-04-01 01:23:52 +01:00
parent ade3a5b589
commit 4913975e99
38 changed files with 648 additions and 756 deletions
@@ -0,0 +1,35 @@
import {
IsNumber,
IsOptional,
IsPositive,
IsString,
Max,
Min,
} from 'class-validator';
export class PaginationOptions {
@IsOptional()
@IsNumber()
@Min(1)
page = 1;
@IsOptional()
@IsNumber()
@IsPositive()
@Min(1)
@Max(100)
limit = 20;
@IsOptional()
@IsString()
query: string;
get offset(): number {
return (this.page - 1) * this.limit;
}
}
export enum PaginationSort {
ASC = 'asc',
DESC = 'desc',
}