Skip to content

@nestarc/pagination ​

Classes ​

InvalidCursorError ​

Defined in: src/errors/invalid-cursor.error.ts:3

Extends ​

  • BadRequestException

Constructors ​

Constructor ​
ts
new InvalidCursorError(cursor): InvalidCursorError;

Defined in: src/errors/invalid-cursor.error.ts:4

Parameters ​
ParameterType
cursorstring
Returns ​

InvalidCursorError

Overrides ​
ts
BadRequestException.constructor

Properties ​

cause ​
ts
cause: unknown;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:28

Exception cause. Indicates the specific original cause of the error. It is used when catching and re-throwing an error with a more-specific or useful error message in order to still have access to the original error.

Inherited from ​
ts
BadRequestException.cause

message ​
ts
message: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from ​
ts
BadRequestException.message

name ​
ts
name: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from ​
ts
BadRequestException.name

stack? ​
ts
optional stack?: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from ​
ts
BadRequestException.stack

stackTraceLimit ​
ts
static stackTraceLimit: number;

Defined in: node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from ​
ts
BadRequestException.stackTraceLimit

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​
ts
BadRequestException.captureStackTrace

createBody() ​
Call Signature ​
ts
static createBody(
   nil,
   message,
   statusCode): HttpExceptionBody;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:74

Parameters ​
ParameterType
nil"" | null
messageHttpExceptionBodyMessage
statusCodenumber
Returns ​

HttpExceptionBody

Inherited from ​
ts
BadRequestException.createBody
Call Signature ​
ts
static createBody(
   message,
   error,
   statusCode): HttpExceptionBody;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:75

Parameters ​
ParameterType
messageHttpExceptionBodyMessage
errorstring
statusCodenumber
Returns ​

HttpExceptionBody

Inherited from ​
ts
BadRequestException.createBody
Call Signature ​
ts
static createBody<Body>(custom): Body;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:76

Type Parameters ​
Type Parameter
Body extends Record<string, unknown>
Parameters ​
ParameterType
customBody
Returns ​

Body

Inherited from ​
ts
BadRequestException.createBody

extractDescriptionAndOptionsFrom() ​
ts
static extractDescriptionAndOptionsFrom(descriptionOrOptions): DescriptionAndOptions;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:84

Utility method used to extract the error description and httpExceptionOptions from the given argument. This is used by inheriting classes to correctly parse both options.

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

DescriptionAndOptions

the error description and the httpExceptionOptions as an object.

Inherited from ​
ts
BadRequestException.extractDescriptionAndOptionsFrom

getDescriptionFrom() ​
ts
static getDescriptionFrom(descriptionOrOptions): string;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:77

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

string

Inherited from ​
ts
BadRequestException.getDescriptionFrom

getHttpExceptionOptionsFrom() ​
ts
static getHttpExceptionOptionsFrom(descriptionOrOptions): HttpExceptionOptions;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:78

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

HttpExceptionOptions

Inherited from ​
ts
BadRequestException.getHttpExceptionOptionsFrom

getResponse() ​
ts
getResponse(): string | object;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:72

Returns ​

string | object

Inherited from ​
ts
BadRequestException.getResponse

getStatus() ​
ts
getStatus(): number;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:73

Returns ​

number

Inherited from ​
ts
BadRequestException.getStatus

initCause() ​
ts
initCause(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:69

Configures error chaining support

Returns ​

void

See ​
Inherited from ​
ts
BadRequestException.initCause

initMessage() ​
ts
initMessage(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:70

Returns ​

void

Inherited from ​
ts
BadRequestException.initMessage

initName() ​
ts
initName(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:71

Returns ​

void

Inherited from ​
ts
BadRequestException.initName

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/@types/node/globals.d.ts:56

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​
ts
BadRequestException.prepareStackTrace

InvalidFilterColumnError ​

Defined in: src/errors/invalid-filter-column.error.ts:3

Extends ​

  • BadRequestException

Constructors ​

Constructor ​
ts
new InvalidFilterColumnError(
   column,
   filterableColumns,
   operator?,
   allowedOperators?): InvalidFilterColumnError;

Defined in: src/errors/invalid-filter-column.error.ts:4

Parameters ​
ParameterType
columnstring
filterableColumnsstring[]
operator?string
allowedOperators?string[]
Returns ​

InvalidFilterColumnError

Overrides ​
ts
BadRequestException.constructor

Properties ​

cause ​
ts
cause: unknown;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:28

Exception cause. Indicates the specific original cause of the error. It is used when catching and re-throwing an error with a more-specific or useful error message in order to still have access to the original error.

Inherited from ​
ts
BadRequestException.cause

message ​
ts
message: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from ​
ts
BadRequestException.message

name ​
ts
name: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from ​
ts
BadRequestException.name

stack? ​
ts
optional stack?: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from ​
ts
BadRequestException.stack

stackTraceLimit ​
ts
static stackTraceLimit: number;

Defined in: node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from ​
ts
BadRequestException.stackTraceLimit

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​
ts
BadRequestException.captureStackTrace

createBody() ​
Call Signature ​
ts
static createBody(
   nil,
   message,
   statusCode): HttpExceptionBody;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:74

Parameters ​
ParameterType
nil"" | null
messageHttpExceptionBodyMessage
statusCodenumber
Returns ​

HttpExceptionBody

Inherited from ​
ts
BadRequestException.createBody
Call Signature ​
ts
static createBody(
   message,
   error,
   statusCode): HttpExceptionBody;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:75

Parameters ​
ParameterType
messageHttpExceptionBodyMessage
errorstring
statusCodenumber
Returns ​

HttpExceptionBody

Inherited from ​
ts
BadRequestException.createBody
Call Signature ​
ts
static createBody<Body>(custom): Body;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:76

Type Parameters ​
Type Parameter
Body extends Record<string, unknown>
Parameters ​
ParameterType
customBody
Returns ​

Body

Inherited from ​
ts
BadRequestException.createBody

extractDescriptionAndOptionsFrom() ​
ts
static extractDescriptionAndOptionsFrom(descriptionOrOptions): DescriptionAndOptions;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:84

Utility method used to extract the error description and httpExceptionOptions from the given argument. This is used by inheriting classes to correctly parse both options.

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

DescriptionAndOptions

the error description and the httpExceptionOptions as an object.

Inherited from ​
ts
BadRequestException.extractDescriptionAndOptionsFrom

getDescriptionFrom() ​
ts
static getDescriptionFrom(descriptionOrOptions): string;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:77

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

string

Inherited from ​
ts
BadRequestException.getDescriptionFrom

getHttpExceptionOptionsFrom() ​
ts
static getHttpExceptionOptionsFrom(descriptionOrOptions): HttpExceptionOptions;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:78

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

HttpExceptionOptions

Inherited from ​
ts
BadRequestException.getHttpExceptionOptionsFrom

getResponse() ​
ts
getResponse(): string | object;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:72

Returns ​

string | object

Inherited from ​
ts
BadRequestException.getResponse

getStatus() ​
ts
getStatus(): number;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:73

Returns ​

number

Inherited from ​
ts
BadRequestException.getStatus

initCause() ​
ts
initCause(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:69

Configures error chaining support

Returns ​

void

See ​
Inherited from ​
ts
BadRequestException.initCause

initMessage() ​
ts
initMessage(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:70

Returns ​

void

Inherited from ​
ts
BadRequestException.initMessage

initName() ​
ts
initName(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:71

Returns ​

void

Inherited from ​
ts
BadRequestException.initName

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/@types/node/globals.d.ts:56

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​
ts
BadRequestException.prepareStackTrace

InvalidSortColumnError ​

Defined in: src/errors/invalid-sort-column.error.ts:3

Extends ​

  • BadRequestException

Constructors ​

Constructor ​
ts
new InvalidSortColumnError(column, sortableColumns): InvalidSortColumnError;

Defined in: src/errors/invalid-sort-column.error.ts:4

Parameters ​
ParameterType
columnstring
sortableColumnsstring[]
Returns ​

InvalidSortColumnError

Overrides ​
ts
BadRequestException.constructor

Properties ​

cause ​
ts
cause: unknown;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:28

Exception cause. Indicates the specific original cause of the error. It is used when catching and re-throwing an error with a more-specific or useful error message in order to still have access to the original error.

Inherited from ​
ts
BadRequestException.cause

message ​
ts
message: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from ​
ts
BadRequestException.message

name ​
ts
name: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from ​
ts
BadRequestException.name

stack? ​
ts
optional stack?: string;

Defined in: node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from ​
ts
BadRequestException.stack

stackTraceLimit ​
ts
static stackTraceLimit: number;

Defined in: node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from ​
ts
BadRequestException.stackTraceLimit

Methods ​

captureStackTrace() ​
ts
static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters ​
ParameterType
targetObjectobject
constructorOpt?Function
Returns ​

void

Inherited from ​
ts
BadRequestException.captureStackTrace

createBody() ​
Call Signature ​
ts
static createBody(
   nil,
   message,
   statusCode): HttpExceptionBody;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:74

Parameters ​
ParameterType
nil"" | null
messageHttpExceptionBodyMessage
statusCodenumber
Returns ​

HttpExceptionBody

Inherited from ​
ts
BadRequestException.createBody
Call Signature ​
ts
static createBody(
   message,
   error,
   statusCode): HttpExceptionBody;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:75

Parameters ​
ParameterType
messageHttpExceptionBodyMessage
errorstring
statusCodenumber
Returns ​

HttpExceptionBody

Inherited from ​
ts
BadRequestException.createBody
Call Signature ​
ts
static createBody<Body>(custom): Body;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:76

Type Parameters ​
Type Parameter
Body extends Record<string, unknown>
Parameters ​
ParameterType
customBody
Returns ​

Body

Inherited from ​
ts
BadRequestException.createBody

extractDescriptionAndOptionsFrom() ​
ts
static extractDescriptionAndOptionsFrom(descriptionOrOptions): DescriptionAndOptions;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:84

Utility method used to extract the error description and httpExceptionOptions from the given argument. This is used by inheriting classes to correctly parse both options.

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

DescriptionAndOptions

the error description and the httpExceptionOptions as an object.

Inherited from ​
ts
BadRequestException.extractDescriptionAndOptionsFrom

getDescriptionFrom() ​
ts
static getDescriptionFrom(descriptionOrOptions): string;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:77

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

string

Inherited from ​
ts
BadRequestException.getDescriptionFrom

getHttpExceptionOptionsFrom() ​
ts
static getHttpExceptionOptionsFrom(descriptionOrOptions): HttpExceptionOptions;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:78

Parameters ​
ParameterType
descriptionOrOptionsstring | HttpExceptionOptions
Returns ​

HttpExceptionOptions

Inherited from ​
ts
BadRequestException.getHttpExceptionOptionsFrom

getResponse() ​
ts
getResponse(): string | object;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:72

Returns ​

string | object

Inherited from ​
ts
BadRequestException.getResponse

getStatus() ​
ts
getStatus(): number;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:73

Returns ​

number

Inherited from ​
ts
BadRequestException.getStatus

initCause() ​
ts
initCause(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:69

Configures error chaining support

Returns ​

void

See ​
Inherited from ​
ts
BadRequestException.initCause

initMessage() ​
ts
initMessage(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:70

Returns ​

void

Inherited from ​
ts
BadRequestException.initMessage

initName() ​
ts
initName(): void;

Defined in: node_modules/@nestjs/common/exceptions/http.exception.d.ts:71

Returns ​

void

Inherited from ​
ts
BadRequestException.initName

prepareStackTrace() ​
ts
static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/@types/node/globals.d.ts:56

Parameters ​
ParameterType
errError
stackTracesCallSite[]
Returns ​

any

See ​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from ​
ts
BadRequestException.prepareStackTrace

PaginateService ​

Defined in: src/paginate.service.ts:12

Constructors ​

Constructor ​
ts
new PaginateService(moduleOptions?, reflector): PaginateService;

Defined in: src/paginate.service.ts:13

Parameters ​
ParameterType
moduleOptionsPaginationModuleOptions
reflectorReflector
Returns ​

PaginateService

Methods ​

paginate() ​
ts
paginate<T>(
   query,
   delegate,
   config,
   handler?): Promise<
  | Paginated<T>
| CursorPaginated<T>>;

Defined in: src/paginate.service.ts:20

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
queryPaginateQuery
delegate{ count: (args) => Promise<number>; findMany: (args) => Promise<T[]>; }
delegate.count(args) => Promise<number>
delegate.findMany(args) => Promise<T[]>
config?PaginateConfig<T>
handler?Function
Returns ​

Promise< | Paginated<T> | CursorPaginated<T>>


PaginationModule ​

Defined in: src/pagination.module.ts:11

Constructors ​

Constructor ​
ts
new PaginationModule(): PaginationModule;
Returns ​

PaginationModule

Methods ​

forRoot() ​
ts
static forRoot(options?): DynamicModule;

Defined in: src/pagination.module.ts:12

Parameters ​
ParameterType
options?PaginationModuleOptions
Returns ​

DynamicModule

forRootAsync() ​
ts
static forRootAsync(options): DynamicModule;

Defined in: src/pagination.module.ts:28

Parameters ​
ParameterType
optionsPaginationModuleAsyncOptions
Returns ​

DynamicModule

Interfaces ​

ApiPaginationQueryOptions ​

Defined in: src/decorators/api-paginated-response.decorator.ts:11

Properties ​

allowWithDeleted? ​
ts
optional allowWithDeleted?: boolean;

Defined in: src/decorators/api-paginated-response.decorator.ts:16

filterableColumns? ​
ts
optional filterableColumns?: Record<string, FilterOperator[]>;

Defined in: src/decorators/api-paginated-response.decorator.ts:15

searchableColumns? ​
ts
optional searchableColumns?: string[];

Defined in: src/decorators/api-paginated-response.decorator.ts:14

sortableColumns? ​
ts
optional sortableColumns?: string[];

Defined in: src/decorators/api-paginated-response.decorator.ts:13

type? ​
ts
optional type?: "offset" | "cursor";

Defined in: src/decorators/api-paginated-response.decorator.ts:12


CursorPaginated ​

Defined in: src/interfaces/paginated.interface.ts:23

Type Parameters ​

Type Parameter
T

Properties ​

data ​
ts
data: T[];

Defined in: src/interfaces/paginated.interface.ts:24

ts
links: {
  current: string;
  next: string | null;
  previous: string | null;
};

Defined in: src/interfaces/paginated.interface.ts:36

current ​
ts
current: string;
next ​
ts
next: string | null;
previous ​
ts
previous: string | null;

meta ​
ts
meta: {
  endCursor: string | null;
  filter?: Record<string, string>;
  hasNextPage: boolean;
  hasPreviousPage: boolean;
  itemsPerPage: number;
  search?: string;
  sortBy: [string, SortOrder][];
  startCursor: string | null;
  totalItems?: number;
};

Defined in: src/interfaces/paginated.interface.ts:25

endCursor ​
ts
endCursor: string | null;
filter? ​
ts
optional filter?: Record<string, string>;
hasNextPage ​
ts
hasNextPage: boolean;
hasPreviousPage ​
ts
hasPreviousPage: boolean;
itemsPerPage ​
ts
itemsPerPage: number;
ts
optional search?: string;
sortBy ​
ts
sortBy: [string, SortOrder][];
startCursor ​
ts
startCursor: string | null;
totalItems? ​
ts
optional totalItems?: number;

PaginateConfig ​

Defined in: src/interfaces/paginate-config.interface.ts:8

Type Parameters ​

Type ParameterDefault type
Tany

Properties ​

allowWithDeleted? ​
ts
optional allowWithDeleted?: boolean;

Defined in: src/interfaces/paginate-config.interface.ts:51

countQuery? ​
ts
optional countQuery?: (args) => Promise<number>;

Defined in: src/interfaces/paginate-config.interface.ts:43

Parameters ​
ParameterType
args{ config: PaginateConfig<T>; delegate: { count: (args) => Promise<number>; }; query: PaginateQuery; where: Record<string, any>; }
args.configPaginateConfig<T>
args.delegate{ count: (args) => Promise<number>; }
args.delegate.count(args) => Promise<number>
args.queryPaginateQuery
args.whereRecord<string, any>
Returns ​

Promise<number>

countStrategy? ​
ts
optional countStrategy?: CountStrategy;

Defined in: src/interfaces/paginate-config.interface.ts:42

cursorColumn? ​
ts
optional cursorColumn?: keyof T & string;

Defined in: src/interfaces/paginate-config.interface.ts:34

Column used as cursor for cursor-based pagination. Defaults to 'id'.

Requirements:

  • Must be included in sortableColumns
  • Should have unique, sequential values (e.g., auto-increment ID, UUID v7, timestamp)
  • Non-unique cursor columns may produce inconsistent results across pages
See ​

https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination

cursorColumns? ​
ts
optional cursorColumns?: keyof T & string[];

Defined in: src/interfaces/paginate-config.interface.ts:36

cursorStrategy? ​
ts
optional cursorStrategy?: CursorStrategy;

Defined in: src/interfaces/paginate-config.interface.ts:35

decodeCursor? ​
ts
optional decodeCursor?: (cursor) => CursorPayload;

Defined in: src/interfaces/paginate-config.interface.ts:38

Parameters ​
ParameterType
cursorstring
Returns ​

CursorPayload

defaultLimit? ​
ts
optional defaultLimit?: number;

Defined in: src/interfaces/paginate-config.interface.ts:39

defaultSortBy? ​
ts
optional defaultSortBy?: [keyof T & string, SortOrder][];

Defined in: src/interfaces/paginate-config.interface.ts:11

encodeCursor? ​
ts
optional encodeCursor?: (payload) => string;

Defined in: src/interfaces/paginate-config.interface.ts:37

Parameters ​
ParameterType
payloadCursorPayload
Returns ​

string

filterableColumns? ​
ts
optional filterableColumns?: { [K in string]?: FilterOperator[] };

Defined in: src/interfaces/paginate-config.interface.ts:16

maxLimit? ​
ts
optional maxLimit?: number;

Defined in: src/interfaces/paginate-config.interface.ts:40

nullSort? ​
ts
optional nullSort?: "first" | "last";

Defined in: src/interfaces/paginate-config.interface.ts:12

paginationType? ​
ts
optional paginationType?: "offset" | "cursor";

Defined in: src/interfaces/paginate-config.interface.ts:23

relations? ​
ts
optional relations?: Record<string, boolean | object>;

Defined in: src/interfaces/paginate-config.interface.ts:20

searchableColumns? ​
ts
optional searchableColumns?: keyof T & string[];

Defined in: src/interfaces/paginate-config.interface.ts:14

select? ​
ts
optional select?: keyof T & string[];

Defined in: src/interfaces/paginate-config.interface.ts:21

sortableColumns ​
ts
sortableColumns: keyof T & string[];

Defined in: src/interfaces/paginate-config.interface.ts:9

where? ​
ts
optional where?: object;

Defined in: src/interfaces/paginate-config.interface.ts:50

withTotalCount? ​
ts
optional withTotalCount?: boolean;

Defined in: src/interfaces/paginate-config.interface.ts:41


Paginated ​

Defined in: src/interfaces/paginated.interface.ts:3

Type Parameters ​

Type Parameter
T

Properties ​

data ​
ts
data: T[];

Defined in: src/interfaces/paginated.interface.ts:4

ts
links: {
  current: string;
  first: string;
  last: string;
  next: string | null;
  previous: string | null;
};

Defined in: src/interfaces/paginated.interface.ts:14

current ​
ts
current: string;
first ​
ts
first: string;
last ​
ts
last: string;
next ​
ts
next: string | null;
previous ​
ts
previous: string | null;

meta ​
ts
meta: {
  currentPage: number;
  filter?: Record<string, string>;
  itemsPerPage: number;
  search?: string;
  sortBy: [string, SortOrder][];
  totalItems?: number;
  totalPages?: number;
};

Defined in: src/interfaces/paginated.interface.ts:5

currentPage ​
ts
currentPage: number;
filter? ​
ts
optional filter?: Record<string, string>;
itemsPerPage ​
ts
itemsPerPage: number;
search? ​
ts
optional search?: string;
sortBy ​
ts
sortBy: [string, SortOrder][];
totalItems? ​
ts
optional totalItems?: number;
totalPages? ​
ts
optional totalPages?: number;

PaginateDefaultsOptions ​

Defined in: src/decorators/paginate-defaults.decorator.ts:6

Properties ​

defaultLimit? ​
ts
optional defaultLimit?: number;

Defined in: src/decorators/paginate-defaults.decorator.ts:7

defaultSortBy? ​
ts
optional defaultSortBy?: [string, SortOrder][];

Defined in: src/decorators/paginate-defaults.decorator.ts:9

maxLimit? ​
ts
optional maxLimit?: number;

Defined in: src/decorators/paginate-defaults.decorator.ts:8

paginationType? ​
ts
optional paginationType?: "offset" | "cursor";

Defined in: src/decorators/paginate-defaults.decorator.ts:10


PaginateQuery ​

Defined in: src/interfaces/paginate-query.interface.ts:3

Properties ​

after? ​
ts
optional after?: string;

Defined in: src/interfaces/paginate-query.interface.ts:15

before? ​
ts
optional before?: string;

Defined in: src/interfaces/paginate-query.interface.ts:16

filter? ​
ts
optional filter?: Record<string, string | string[]>;

Defined in: src/interfaces/paginate-query.interface.ts:7

limit? ​
ts
optional limit?: number;

Defined in: src/interfaces/paginate-query.interface.ts:4

page? ​
ts
optional page?: number;

Defined in: src/interfaces/paginate-query.interface.ts:12

path ​
ts
path: string;

Defined in: src/interfaces/paginate-query.interface.ts:9

search? ​
ts
optional search?: string;

Defined in: src/interfaces/paginate-query.interface.ts:6

sortBy? ​
ts
optional sortBy?: [string, SortOrder][];

Defined in: src/interfaces/paginate-query.interface.ts:5

withDeleted? ​
ts
optional withDeleted?: boolean;

Defined in: src/interfaces/paginate-query.interface.ts:8


PaginationModuleAsyncOptions ​

Defined in: src/interfaces/pagination-options.interface.ts:14

Extends ​

  • Pick<ModuleMetadata, "imports">

Properties ​

imports? ​
ts
optional imports?: (
  | DynamicModule
  | Type<any>
  | Promise<DynamicModule>
  | ForwardReference<any>)[];

Defined in: node_modules/@nestjs/common/interfaces/modules/module-metadata.interface.d.ts:18

Optional list of imported modules that export the providers which are required in this module.

Inherited from ​
ts
Pick.imports

inject? ​
ts
optional inject?: any[];

Defined in: src/interfaces/pagination-options.interface.ts:19

useFactory ​
ts
useFactory: (...args) =>
  | PaginationModuleOptions
| Promise<PaginationModuleOptions>;

Defined in: src/interfaces/pagination-options.interface.ts:16

Parameters ​
ParameterType
...argsany[]
Returns ​

| PaginationModuleOptions | Promise<PaginationModuleOptions>


PaginationModuleOptions ​

Defined in: src/interfaces/pagination-options.interface.ts:4

Properties ​

defaultLimit? ​
ts
optional defaultLimit?: number;

Defined in: src/interfaces/pagination-options.interface.ts:5

defaultPaginationType? ​
ts
optional defaultPaginationType?: "offset" | "cursor";

Defined in: src/interfaces/pagination-options.interface.ts:7

defaultSortBy? ​
ts
optional defaultSortBy?: [string, SortOrder][];

Defined in: src/interfaces/pagination-options.interface.ts:8

fieldNamingStrategy? ​
ts
optional fieldNamingStrategy?: "camelCase" | "snake_case";

Defined in: src/interfaces/pagination-options.interface.ts:11

maxLimit? ​
ts
optional maxLimit?: number;

Defined in: src/interfaces/pagination-options.interface.ts:6

ts
optional withLinks?: boolean;

Defined in: src/interfaces/pagination-options.interface.ts:9

withTotalCount? ​
ts
optional withTotalCount?: boolean;

Defined in: src/interfaces/pagination-options.interface.ts:10

Type Aliases ​

CountStrategy ​

ts
type CountStrategy = "exact" | "none" | "custom";

Defined in: src/interfaces/paginate-config.interface.ts:5


FilterOperator ​

ts
type FilterOperator =
  | "$eq"
  | "$ne"
  | "$gt"
  | "$gte"
  | "$lt"
  | "$lte"
  | "$in"
  | "$nin"
  | "$ilike"
  | "$btw"
  | "$null"
  | "$not:null";

Defined in: src/interfaces/filter-operator.type.ts:1


SortOrder ​

ts
type SortOrder = "ASC" | "DESC";

Defined in: src/interfaces/filter-operator.type.ts:15

Variables ​

Paginate ​

ts
const Paginate: (...dataOrPipes) => ParameterDecorator;

Defined in: src/decorators/paginate.decorator.ts:5

Parameters ​

ParameterType
...dataOrPipesunknown[]

Returns ​

ParameterDecorator


PAGINATE_DEFAULTS_KEY ​

ts
const PAGINATE_DEFAULTS_KEY: "PAGINATE_DEFAULTS" = 'PAGINATE_DEFAULTS';

Defined in: src/decorators/paginate-defaults.decorator.ts:4


PAGINATION_MODULE_OPTIONS ​

ts
const PAGINATION_MODULE_OPTIONS: "PAGINATION_MODULE_OPTIONS" = 'PAGINATION_MODULE_OPTIONS';

Defined in: src/pagination.constants.ts:1

Functions ​

ApiCursorPaginatedResponse() ​

ts
function ApiCursorPaginatedResponse(dataDto, queryOptions?): MethodDecorator;

Defined in: src/decorators/api-paginated-response.decorator.ts:68

Parameters ​

ParameterType
dataDtoType
queryOptionsOmit<ApiPaginationQueryOptions, "type">

Returns ​

MethodDecorator


ApiPaginatedResponse() ​

ts
function ApiPaginatedResponse(dataDto, queryOptions?): MethodDecorator;

Defined in: src/decorators/api-paginated-response.decorator.ts:19

Parameters ​

ParameterType
dataDtoType
queryOptionsOmit<ApiPaginationQueryOptions, "type">

Returns ​

MethodDecorator


ApiPaginationQuery() ​

ts
function ApiPaginationQuery(options?): MethodDecorator;

Defined in: src/decorators/api-paginated-response.decorator.ts:116

Parameters ​

ParameterType
optionsApiPaginationQueryOptions

Returns ​

MethodDecorator


paginate() ​

ts
function paginate<T>(
   query,
   delegate,
   config): Promise<
  | Paginated<T>
| CursorPaginated<T>>;

Defined in: src/paginate.ts:23

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
queryPaginateQuery
delegate{ count: (args) => Promise<number>; findMany: (args) => Promise<T[]>; }
delegate.count(args) => Promise<number>
delegate.findMany(args) => Promise<T[]>
configPaginateConfig<T>

Returns ​

Promise< | Paginated<T> | CursorPaginated<T>>


PaginateDefaults() ​

ts
function PaginateDefaults(defaults): CustomDecorator<string>;

Defined in: src/decorators/paginate-defaults.decorator.ts:13

Parameters ​

ParameterType
defaultsPaginateDefaultsOptions

Returns ​

CustomDecorator<string>

Released under the MIT License.