Skip to content

ItemPaginateSelector

Selects Items of any Template with offset paging.

TItem

The type of each result.

archived(include): this

Chooses whether archived Items are left out, included, or the only results.

boolean | "exclude" | "include" | "only"

true or 'include' to include archived Items, 'only' for archived Items alone, false or 'exclude' to leave them out.

this

Archived Items are left out until this is called.

BaseSelector.archived


assign(input): this

Applies the criteria of an ItemQuery, such as one received from a client, over the current criteria.

ItemQuery

The query to apply; it is validated before use.

this

when input is not a valid ItemQuery.

BaseSelector.assign


debug(): this

Logs the resolved query when the selection runs.

this

BaseSelector.debug


execute(): Promise<PageSelectorResult<TItem>>

Runs the selection and returns the requested page with its totals.

Promise<PageSelectorResult<TItem>>

PaginateSelector.execute


exists(): Promise<boolean>

Checks whether anything matches the selection, without ordering or reading the results, so the database can stop at the first match.

Promise<boolean>

Whether at least one Item matches.

Cheaper than first() on a large set of matches, which sorts every match to find the first. Unlike first() and execute(), the check is not permission filtered: it is true when an Item matches whatever the active principal can read (as with totalCount of a paginated selection). Run it with sudo for a yes/no question about Items the principal may not read.

BaseSelector.exists


first(): Promise<TItem | undefined>

Runs the selection for a single result.

Promise<TItem | undefined>

The first result, or undefined when nothing matches.

PaginateSelector.first


id(itemOrItems): this

Restricts results to the given Items.

SelectorIdInput

One or more identifiers; an empty list matches nothing.

this

BaseSelector.id


key(key): this

Restricts results to Items carrying one of the given keys.

string | string[]

One or more keys; each must be a valid key.

this

BaseSelector.key


limit(value): this

Sets the page size.

number

A positive integer.

this

(error-008-invalid-selector-limit) when value is not a positive integer.

PaginateSelector.limit


onlyPrn(prn): TemplateItemPaginateSelector<TItem>

Narrows the selection to the given Template or Union PRNs, replacing any given earlier.

string | string[]

One or more Template or Union PRNs.

TemplateItemPaginateSelector<TItem>


parent(parentOrParents): this

Restricts results to direct children of the given parents.

SelectorIdInput

One or more parent identifiers; an empty list matches nothing.

this

BaseSelector.parent


prn(prn): TemplateItemPaginateSelector<TItem>

Narrows the selection to Items of the given Template or Union PRNs, in addition to any given earlier.

string | string[]

One or more Template or Union PRNs.

TemplateItemPaginateSelector<TItem>


search(idx, query): this

Restricts results to Items matching a search query against a search index.

ReadSearchIndexInstance

The search index to query.

SearchQuery

The term and facets to match.

this

BaseSelector.search


state(state): this

Restricts results to Items in one of the given states.

string | string[]

One or more state keys; an empty list removes the state criterion.

this

BaseSelector.state


template(template): TemplateItemPaginateSelector<TItem>

Narrows the selection to Items of a Template, in addition to any Templates or Unions given earlier.

The Template.

string

TemplateItemPaginateSelector<TItem>


union(template): TemplateItemCursorSelector<TItem>

Narrows the selection to Items of a Union’s member Templates, in addition to any Templates or Unions given earlier.

The Union.

string

TemplateItemCursorSelector<TItem>