The table or model the view selects from.
OptionalschemaSchema qualifying from. Defaults to the source model's own schema.
OptionalattributesColumns the view exposes. Omit to select every column.
Attribute names are used exactly as findAll() uses them, so a view built
from a model selects the same columns a query on that model would.
OptionalwhereRow filter, in the usual operator syntax.
OptionalincludeJoins to other models, same as findAll({ include }).
OptionalorderOrdering. Note that several databases ignore ORDER BY inside a view.
OptionalgroupGROUP BY column(s).
OptionalhavingHAVING filter, applied after grouping.
OptionallimitRow cap. Not permitted inside a view by every database.
OptionaloffsetRow offset.
OptionaldistinctSELECT DISTINCT.
OptionaldistinctPostgreSQL SELECT DISTINCT ON (...).
OptionalcteCommon table expressions prepended as a WITH clause. Each body may itself
be a ViewDefinition, so a view with CTEs needs no SQL either.
OptionalunionQueries combined with the main one.
OptionalunionHow union entries are combined. Defaults to UNION.
A view body expressed as query options rather than SQL.
Every field means what it means in
findAll().attributesaccepts the same rich forms — plain columns,[expression, alias]tuples, andfn()/col()/cast()expressions — so aggregates need no SQL either: