OptionalnameOptionaldefinitionWhat 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.
OptionalqueryThe SELECT statement that defines the view.
OptionalqueryA function that returns the SELECT statement. Useful when the query depends on runtime values or other model table names.
OptionalschemaOptional schema prefix (e.g. 'public' for PostgreSQL).
OptionalreplaceIf true, generates CREATE OR REPLACE VIEW. Default: false.
OptionalcheckPostgreSQL only: if true, the view will be marked WITH CHECK OPTION.
OptionaldialectTarget dialect for DDL generation. One of: 'mysql' | 'mariadb' | 'postgres' | 'sqlite' Defaults to 'mysql'.
OptionalmaterializedPostgreSQL only: if true generates a MATERIALIZED VIEW.
The view name in the database. Defaults to the class name (snake_cased) if not provided.