prorm API Reference
    Preparing search index...

    Interface ViewOptions

    interface ViewOptions {
        name?: string;
        definition?: ViewDefinition;
        query?: string;
        queryFn?: () => string;
        schema?: string;
        replace?: boolean;
        checkOption?: boolean | "CASCADED" | "LOCAL";
        dialect?: "mysql" | "mariadb" | "postgres" | "sqlite";
        materialized?: boolean;
    }
    Index
    name?: string

    The view name in the database. Defaults to the class name (snake_cased) if not provided.

    definition?: ViewDefinition

    What the view selects, as query options rather than SQL — the preferred form, and the only one that is portable across dialects:

    @View({ name: 'active_users', definition: { from: 'users', where: { status: 'active' } } })
    class ActiveUser extends Model {}

    Compiling a definition needs a dialect, so pass one to getSQL() or use ViewRegistry.createView(prorm, Target), which takes it from the instance.

    query?: string

    The SELECT statement that defines the view.

    Prefer definition, which is built for the target dialect instead of written by hand. One of definition, query or queryFn must be provided.

    queryFn?: () => string

    A function that returns the SELECT statement. Useful when the query depends on runtime values or other model table names.

    Prefer definition.

    schema?: string

    Optional schema prefix (e.g. 'public' for PostgreSQL).

    replace?: boolean

    If true, generates CREATE OR REPLACE VIEW. Default: false.

    checkOption?: boolean | "CASCADED" | "LOCAL"

    PostgreSQL only: if true, the view will be marked WITH CHECK OPTION.

    dialect?: "mysql" | "mariadb" | "postgres" | "sqlite"

    Target dialect for DDL generation. One of: 'mysql' | 'mariadb' | 'postgres' | 'sqlite' Defaults to 'mysql'.

    materialized?: boolean

    PostgreSQL only: if true generates a MATERIALIZED VIEW.