View as Markdown

API reference: @salmonui/data/server

JsonQueryHandlerOptionsinterface

import type { JsonQueryHandlerOptions } from '@salmonui/data/server';
interface JsonQueryHandlerOptions {
    readonly key: string;
    readonly fields?: readonly string[];
    readonly types?: Readonly<Record<string, WireType>>;
    readonly dict?: readonly string[] | 'auto';
    readonly parentField?: string;
    readonly versionField?: string;
    readonly validate?: (row: Obj) => readonly {
        readonly field?: string;
        readonly code: string;
        readonly message: string;
    }[];
    readonly nextKey?: () => Json;
    readonly facetLimit?: number;
    readonly lookups?: Readonly<Record<string, readonly Obj[]>>;
    readonly lookupFields?: Readonly<Record<string, {
        readonly lookup: string;
        readonly keyField: string;
        readonly displayField: string;
    }>>;
}
JsonQueryHandlerOptions members (11)
NameSignatureDescription
keyreadonly key: string;
fieldsoptionalreadonly fields?: readonly string[];

Full field list (default: keys of the first row).

typesoptionalreadonly types?: Readonly<Record<string, WireType>>;

Wire types per field (default: inferred from the first row; Date values are date).

dictoptionalreadonly dict?: readonly string[] | 'auto';

Dictionary-encode these string fields, or 'auto'. Default none.

parentFieldoptionalreadonly parentField?: string;

Tree data: field holding the parent key (blank for roots). Tree reads (parent, null for the root level) return that level's children with childCounts; with a filter or search they return every match with its ancestor chain (filterMode: 'ancestors') in pre-order, with parents, depths, and childCounts of the kept children, paged by top-level row. Aggregates cover the kept rows of every depth. Writes: parents sets the parent of added rows, deleting a row deletes its subtree, moved sets the parent of moved rows and places them next to target.

versionFieldoptionalreadonly versionField?: string;

Row version field; incremented on every change and checked against version.

validateoptionalreadonly validate?: (row: Obj) => readonly { readonly field?: string; readonly code: string; readonly message: string; }[];

Validation for added and changed rows.

nextKeyoptionalreadonly nextKey?: () => Json;

Key generator for added rows whose key is null.

facetLimitoptionalreadonly facetLimit?: number;

Max facet entries. Default 1000.

lookupsoptionalreadonly lookups?: Readonly<Record<string, readonly Obj[]>>;

Lookup tables answered for { v: 1, lookup: { name, keys, keyField } }.

lookupFieldsoptionalreadonly lookupFields?: Readonly<Record<string, { readonly lookup: string; readonly keyField: string; readonly displayField: string; }>>;

Fields holding a lookup key (lookup / foreign-key columns): sorting and grouping by such a field order rows and groups by the displayField of the matching row of lookups[lookup] (a server-side join), then by the key. Group keys, filters and the returned rows keep the key.