跳到主要内容

ui/build/collection-query/collection-query-state.svelte

ui/build/collection-query/collection-query-state.svelte

Classes

CollectionQueryState

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:44

The one search + filter + pagination model a collection surface binds.

Every surface used to keep its own three pieces of state and its own rule for how they interact, and the rule is the part that kept going wrong. Narrowing a result set invalidates the page you are on: filter a six-page board down to one page while sitting on page four and the query asks for rows past the end, so the surface renders empty and reads as broken. CollectionTable knew this and called resetToFirstPage(); the roster month board knew it too and assigned boardPage = 0 by hand in five separate handlers, which is five chances to forget.

Here the reset is not something a caller remembers to do — setSearch and setFilters own it, because it is a property of the model rather than of any one surface.

Type Parameters

Type Parameter Default type
TRow extends object CollectionRecord

Constructors

Constructor
new CollectionQueryState<TRow>(options?): CollectionQueryState<TRow>;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:46

Parameters
Parameter Type
options? CollectionQueryStateOptions<TRow>
Returns

CollectionQueryState<TRow>

Accessors

filters
Get Signature
get filters(): readonly CollectionFilter[];

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:48

Returns

readonly CollectionFilter[]

narrowed
Get Signature
get narrowed(): boolean;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:52

True while the result set is narrowed, so a surface can offer "clear" without recomputing.

Returns

boolean

pageIndex
Get Signature
get pageIndex(): number;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:49

Returns

number

pageSize
Get Signature
get pageSize(): number;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:50

Returns

number

queryOptions
Get Signature
get queryOptions(): CollectionFilterOptions;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:64

What the generated client takes.

The wire path is a mutable string[], so this copies rather than casts: the state's own tuples stay readonly and a consumer cannot reach through the query options to mutate them.

Returns

CollectionFilterOptions

Get Signature
get search(): string;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:47

Returns

string

Methods

clear()
clear(): void;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:57

Returns

void

setFilters()
setFilters(filters): void;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:54

Parameters
Parameter Type
filters readonly CollectionFilter[]
Returns

void

setPageIndex()
setPageIndex(pageIndex): void;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:55

Parameters
Parameter Type
pageIndex number
Returns

void

setPageSize()
setPageSize(pageSize): void;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:56

Parameters
Parameter Type
pageSize number
Returns

void

setSearch()
setSearch(search): void;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:53

Parameters
Parameter Type
search string
Returns

void

Interfaces

CollectionQueryStateOptions

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:15

Type Parameters

Type Parameter
TRow extends object

Properties

filters?
readonly optional filters?: readonly TypedCollectionFilter<TRow>[];

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:17

pageSize?
readonly optional pageSize?: number;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:18

persistenceKey?
readonly optional persistenceKey?: string;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:28

View key the page size is remembered against.

Only the page size. How many rows you want to see at once is a preference about the surface; the search, the filters and the page you are on are the question you asked on this visit, and a surface that restores them answers a question nobody has asked yet. Page index in particular cannot be restored honestly by a cursor-paged surface: the cursors are rebuilt from scratch on mount, so a remembered "page 4" would label the first page as the fourth.

readonly optional search?: string;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:16


TypedCollectionFilter

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:10

Type Parameters

Type Parameter
TRow extends object

Properties

operand?
readonly optional operand?: unknown;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:13

operator
readonly operator:
  | "eq"
  | "ne"
  | "gt"
  | "gte"
  | "lt"
  | "lte"
  | "ilike"
  | "isNull"
  | "isNotNull"
  | "arrayContains"
  | "arrayOverlaps"
  | "contains_date"
  | "overlaps";

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:12

path
readonly path: CollectionFilterPath<TRow>;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:11

Type Aliases

CollectionFilterPath

type CollectionFilterPath<TRow> =
  | readonly [Extract<keyof TRow, string>]
  | readonly [Extract<keyof TRow, string>, string];

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:9

A filter path checked against the row it filters.

CollectionFilter.path on the wire is string[] — nothing stops a surface from filtering on a field the collection does not have, and nothing tells you it happened; the query simply returns everything or nothing. One hop for a column on the row, two for a column on an expanded relation.

Type Parameters

Type Parameter
TRow extends object

Variables

DEFAULT_COLLECTION_PAGE_SIZE

const DEFAULT_COLLECTION_PAGE_SIZE: 50 = 50;

Defined in: apps/website/.api-docs-entry/ui/build/collection-query/collection-query-state.svelte.d.ts:30