mirror of
https://github.com/docmost/docmost.git
synced 2026-05-22 18:22:42 +08:00
server: refactor pagination
* fix transaction usgae in repos * other bug fixes
This commit is contained in:
@@ -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',
|
||||
}
|
||||
Reference in New Issue
Block a user