UnionCursorSelector
Selects Items across the member Templates of a Union with cursor paging, as returned by selectItems on a Union.
Extends
Section titled “Extends”BaseSelector.CursorSelector<TItem>.BaseFilterSelector.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
cursor()
Section titled “cursor()”cursor(
value):this
Resumes the selection from a cursor returned with an earlier page.
Parameters
Section titled “Parameters”The cursor, a cursor with a new page size, or undefined to start from the beginning.
Returns
Section titled “Returns”this
Throws
Section titled “Throws”when called on a selection that has switched to offset pagination.
Inherited from
Section titled “Inherited from”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<CursorSelectorResult<TItem>>
Runs the selection and returns one page of results with the cursor for the next page.
Returns
Section titled “Returns”Promise<CursorSelectorResult<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
iterator()
Section titled “iterator()”iterator():
AsyncGenerator<TItem,void,undefined>
Yields every result across all pages, fetching each page on demand at the current page size.
Returns
Section titled “Returns”AsyncGenerator<TItem, void, undefined>
Example
Section titled “Example”Walk every child of a Template
for await (const group of item.selectChildren().template(demographicGroup).iterator()) { // ...}Inherited from
Section titled “Inherited from”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, starting from a Relation declared on the Union; each hop replaces the selection with the Items on the far side of that Relation.
Returns
Section titled “Returns”this
Throws
Section titled “Throws”when 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”onlyPrn()
Section titled “onlyPrn()”onlyPrn(
prn):UnionCursorSelector<TItem>
Narrows the selection to the given Template or Union PRNs, replacing any given earlier.
Parameters
Section titled “Parameters”string | string[]
One or more Template or Union PRNs.
Returns
Section titled “Returns”UnionCursorSelector<TItem>
paginate()
Section titled “paginate()”paginate(
options):UnionPaginateSelector<TItem>
Switches the selection to offset paging for one page.
Parameters
Section titled “Parameters”options
Section titled “options”The 1-based page and page size.
Returns
Section titled “Returns”UnionPaginateSelector<TItem>
Throws
Section titled “Throws”(error-008-invalid-selector-limit) when the page size is not a positive integer.
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
prn(
prn):UnionCursorSelector<TItem>
Narrows the selection to the given Template or Union PRNs, in addition to any given earlier.
Parameters
Section titled “Parameters”string | string[]
One or more Template or Union PRNs.
Returns
Section titled “Returns”UnionCursorSelector<TItem>
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
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
template()
Section titled “template()”template(
template):UnionCursorSelector<TItem>
Narrows the selection to Items of a Template, in addition to the Union’s members.
Parameters
Section titled “Parameters”template
Section titled “template”The Template.
string
Returns
Section titled “Returns”UnionCursorSelector<TItem>

