TemplateItemPaginateSelector
Selects Items narrowed to a Template or Union with offset paging, adding Property filters, sorting and joins.
Extends
Section titled “Extends”BaseSelector.PaginateSelector<TItem>.BaseFilterSelector.BaseSortableSelector.BaseHierarchySelector
Type Parameters
Section titled “Type Parameters”TItem
The type of each result.
Methods
Section titled “Methods”archived()
Section titled “archived()”archived(
include):this
Chooses whether archived Items are left out, included, or the only results.
Parameters
Section titled “Parameters”include
Section titled “include”boolean | "exclude" | "include" | "only"
true or 'include' to include archived Items, 'only' for archived Items alone, false or
'exclude' to leave them out.
Returns
Section titled “Returns”this
Remarks
Section titled “Remarks”Archived Items are left out until this is called.
Inherited from
Section titled “Inherited from”BaseSelector.archived
assign()
Section titled “assign()”assign(
input):this
Applies the criteria of an ItemQuery, such as one received from a client, over the current criteria.
Parameters
Section titled “Parameters”The query to apply; it is validated before use.
Returns
Section titled “Returns”this
Throws
Section titled “Throws”when input is not a valid ItemQuery.
Inherited from
Section titled “Inherited from”BaseSelector.assign
debug()
Section titled “debug()”debug():
this
Logs the resolved query when the selection runs.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseSelector.debug
execute()
Section titled “execute()”execute():
Promise<PageSelectorResult<TItem>>
Runs the selection and returns the requested page with its totals.
Returns
Section titled “Returns”Promise<PageSelectorResult<TItem>>
Inherited from
Section titled “Inherited from”exists()
Section titled “exists()”exists():
Promise<boolean>
Checks whether anything matches the selection, without ordering or reading the results, so the database can stop at the first match.
Returns
Section titled “Returns”Promise<boolean>
Whether at least one Item matches.
Remarks
Section titled “Remarks”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.
Inherited from
Section titled “Inherited from”BaseSelector.exists
filter()
Section titled “filter()”filter(
condition):this
Restricts results to Items satisfying a condition on their Properties or Relations.
Parameters
Section titled “Parameters”condition
Section titled “condition”A Property condition ($equals, $in, $includes, $range), a Relation condition
($exists, $notExists) or a logical combination ($and, $or, $not).
Returns
Section titled “Returns”this
Throws
Section titled “Throws”when the condition is malformed, or (error-015-property-not-indexed) when a Property condition
is used before the selection is narrowed to a Template or Union.
Example
Section titled “Example”Match a Property value
const match = await participant.selectItems().filter({ operator: '$equals', key: 'slackUserId', value: input.slackUserId }).first();Inherited from
Section titled “Inherited from”BaseFilterSelector.filter
first()
Section titled “first()”first():
Promise<TItem|undefined>
Runs the selection for a single result.
Returns
Section titled “Returns”Promise<TItem | undefined>
The first result, or undefined when nothing matches.
Inherited from
Section titled “Inherited from”id(
itemOrItems):this
Restricts results to the given Items.
Parameters
Section titled “Parameters”itemOrItems
Section titled “itemOrItems”One or more identifiers; an empty list matches nothing.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseSelector.id
join()
Section titled “join()”join(…
relations):this
Replaces the selection with the Items on the far side of a Relation of the selected Items.
Parameters
Section titled “Parameters”relations
Section titled “relations”…[string, ...string[]]
The keys of the Relations to follow, in order; each hop replaces the selection with the Items on the far side of that Relation, navigable from either side.
Returns
Section titled “Returns”this
Throws
Section titled “Throws”when the selection is not narrowed to a single Template or Union, or the Relation key is unknown.
joinChildren()
Section titled “joinChildren()”joinChildren(
child,options?):this
Turns a selection of parents into a selection of their children of a Template or Union.
Parameters
Section titled “Parameters”The Template or Union of the children.
string
options?
Section titled “options?”Whether to keep children whose parent did not match.
joinType?
Section titled “joinType?”"inner" | "left"
Join mode. An inner join keeps only Items whose counterpart matched; a left join keeps every Item of the joined Template or Union.
Default Value
'inner'
Returns
Section titled “Returns”this
Remarks
Section titled “Remarks”Set the parents’ sort before calling, then use sort(['cascade', ...]) on the result to order
children by a parent Property first and their own Properties second.
Example
Section titled “Example”Children of matching parents, ordered by parent then title
const things = await category .selectItems() .sort(['title asc']) .joinChildren(thing) .sort(['cascade', { direction: 'ascending', key: 'title', caseInsensitive: true }]) .execute();Inherited from
Section titled “Inherited from”BaseHierarchySelector.joinChildren
joinParents()
Section titled “joinParents()”joinParents(
parent,options?):this
Turns a selection of children into a selection of their parents of a Template or Union.
Parameters
Section titled “Parameters”parent
Section titled “parent”The Template or Union of the parents.
string
options?
Section titled “options?”Whether to keep parents without a matching child.
joinType?
Section titled “joinType?”"inner" | "left"
Join mode. An inner join keeps only Items whose counterpart matched; a left join keeps every Item of the joined Template or Union.
Default Value
'inner'
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseHierarchySelector.joinParents
key(
key):this
Restricts results to Items carrying one of the given keys.
Parameters
Section titled “Parameters”string | string[]
One or more keys; each must be a valid key.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseSelector.key
limit()
Section titled “limit()”limit(
value):this
Sets the page size.
Parameters
Section titled “Parameters”number
A positive integer.
Returns
Section titled “Returns”this
Throws
Section titled “Throws”(error-008-invalid-selector-limit) when value is not a positive integer.
Inherited from
Section titled “Inherited from”parent()
Section titled “parent()”parent(
parentOrParents):this
Restricts results to direct children of the given parents.
Parameters
Section titled “Parameters”parentOrParents
Section titled “parentOrParents”One or more parent identifiers; an empty list matches nothing.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseSelector.parent
search()
Section titled “search()”search(
idx,query):this
Restricts results to Items matching a search query against a search index.
Parameters
Section titled “Parameters”The search index to query.
The term and facets to match.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseSelector.search
sort()
Section titled “sort()”sort(
condition):this
Orders results by up to two terms.
Parameters
Section titled “Parameters”condition
Section titled “condition”One or two terms. A term is a Property sort (key, direction, optional caseInsensitive
or ordinal), an intrinsic sort on createdAt or state (intrinsic: true), a shortcut string such as
'title asc' or '$createdAt desc', or 'cascade' to place a joined query’s sort at that position.
Returns
Section titled “Returns”this
Remarks
Section titled “Remarks”Items without a value for a term sort last ascending and first descending. Property sorts require the selection to be narrowed to a Template or Union.
Throws
Section titled “Throws”when a term is malformed, or (error-015-property-not-indexed) when a Property sort is used before
the selection is narrowed to a Template or Union.
Example
Section titled “Example”Order by a Property
const ordered = content.selectItems().sort([{ direction: 'ascending', key: 'title' }]);Inherited from
Section titled “Inherited from”BaseSortableSelector.sort
state()
Section titled “state()”state(
state):this
Restricts results to Items in one of the given states.
Parameters
Section titled “Parameters”string | string[]
One or more state keys; an empty list removes the state criterion.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BaseSelector.state

