import { RefreshMaterializedViewResult } from "./native"; import { Table } from "./table"; /** Schema metadata key holding a materialized view's definition. */ export declare const DEFINITION_META_KEY = "mv.definition"; /** * The newest stored layout this version reads: `{"format": N, "query": ""}`, * format 2 being a query with `GROUP BY`, format 3 native pairs and format 4 * native dedup results. */ export declare const DEFINITION_FORMAT = 4; /** * The query that defines a materialized view, as stored: * `SELECT columns FROM [ns.]table [, function(args) AS alias | , UNNEST(column) AS alias] * [WHERE predicate] [GROUP BY expr, ...] [LIMIT n]`. A Function in `FROM` * position yields one row per element it returns. */ export interface MaterializedViewDefinition { /** The defining query, in the canonical spelling the server stores. */ query: string; } /** * The view's columns: column names, `[alias, SQL expression]` pairs, or a * record of the same. A bare name projects itself. */ export type MaterializedViewSelect = (string | [string, string])[] | Record; /** * @internal Reject a numeric option N-API would otherwise silently coerce: * `Infinity` reaches Rust as 0, `1.5` as 1. */ export declare function validateNonNegativeInteger(value: number | undefined, name: string): void; /** * @internal Normalize a select argument into `[alias, expression]` pairs. * A bare name projects itself and is quoted, so any valid column name works; * pair and record entries are kept verbatim because their right side is an * expression. */ export declare function normalizeSelect(select?: MaterializedViewSelect): [string, string][] | undefined; /** @internal Parse a definition off a table's stored schema metadata. */ export declare function definitionFromMetadata(metadata: Map, name: string): MaterializedViewDefinition; /** @internal Parse the backend-independent definition returned by native code. */ export declare function definitionFromJson(raw: string, name: string): MaterializedViewDefinition; /** * A handle on a materialized view: its table plus its definition. * * Obtained from {@link Connection#createMaterializedView} or * {@link Connection#openMaterializedView}. The view is a normal table -- * queries, indexes and search all apply through {@link MaterializedView#table} * -- whose contents are maintained by {@link MaterializedView#refresh}. */ export declare class MaterializedView { private readonly inner; constructor(table: Table); get name(): string; /** The view, as the table it is. */ table(): Table; /** The query that defines the view. */ definition(): Promise; /** * Recompute the view from its source. * * The refresh is incremental when the source's changes can be reconciled * into the view -- rows added, changed or removed since the last one -- * and otherwise rebuilds. `full` forces a rebuild; `sourceVersion` * refreshes to that source version instead of the latest. * * Concurrent refreshes of one view do not duplicate its rows. Two that * plan the same source rows conflict on commit, and the loser throws * rather than writing them a second time. */ refresh(options?: { full?: boolean; sourceVersion?: number; }): Promise; }