PagingParams

Defines a data transfer object used to pass paging parameters for queries.

Description

The PagingParams class allows you to create data transfer objects used to pass paging parameters for queries.

Important points

  • A page is defined by two parameters:
    • skip: number of items to skip.
    • take: number of items to return in a page.
  • Additionally, the optional total parameter defines whether to return the total number of items or not.
  • However, not all implementations support the total parameter, because its generation may lead to severe performance implications.

Constructors

Creates a new instance and sets its values.

public constructor(skip: number = null, take: number = null, total: boolean = null)

  • skip: number - the number of items to skip.
  • take: number - the number of items to return.
  • total: boolean - true to return the total number of items.

Fields

skip

The number of items to skip.

public skip: number

take

The number of items to return.

public take: number

total

The flag to return the total number of items.

public total: boolean

Instance methods

getSkip

Gets the number of items to skip.

public getSkip(minSkip: number): number

  • minSkip: number - the minimum number of items to skip.
  • returns: number - the number of items to skip.

getTake

Gets the number of items to return in a page.

public getTake(maxTake: number): number

  • maxTake: number - the maximum number of items to return.
  • returns: number - the number of items to return.

Static methods

fromMap

Creates a new PagingParams and sets it parameters from the specified map

public static fromMap(map: any): PagingParams

  • map: any - a AnyValueMap or StringValueMap to initialize this PagingParams
  • returns: PagingParams - a newly created PagingParams.

fromTuples

Creates a new PagingParams from a list of key-value pairs called tuples.

public static fromTuples(…tuples: any[]): PagingParams

  • tuples: any[] - a list of values where odd elements are keys and the following even elements are values
  • returns: PagingParams - a newly created PagingParams.

fromValue

Converts specified value into PagingParams.

public static fromValue(value: any): PagingParams

  • value: any - value to be converted
  • returns: PagingParams - a newly created PagingParams.

Examples

let filter = FilterParams.fromTuples("type", "Type1");
let paging = new PagingParams(0, 100);
    
myDataClient.getDataByFilter(filter, paging, (err, page) => {...});