# BaseModel.getViewDefinition() method · @imqueue/pg-sequelize

Source: https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.basemodel.getviewdefinition/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-sequelize 4.2.0 — generated reference, not hand-written

This view's SQL, with any dynamic parameters substituted in.

**Signature:**

```typescript
static getViewDefinition(viewParams?: ViewParams, asQuery?: boolean): string;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| viewParams | [ViewParams](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.viewparams/) | _(Optional)_ Values overriding the decorated defaults. |
| asQuery | boolean | _(Optional)_ Strips the leading create-view clause, leaving a statement that can be embedded as a subquery. This is how a dynamic view is spliced into a `FROM` or a join. |


**Returns:**

string

The definition, whitespace-normalised and ending in a semicolon.

## Remarks

Parameters are merged in two layers: the defaults given to `DynamicView`, then whatever is passed here. Each `@{name}` placeholder in the definition is replaced with the escaped value, which is what makes it safe to pass a caller's input — though only numbers and strings render as values, and everything else, including a missing parameter, becomes `NULL`.

