Skip to content

postgrelize / DestroyOptions

Type Alias: DestroyOptions<T> ​

DestroyOptions<T> = QueryOptionsBase & object & BulkHookOptions

Defined in: src/model/bulk-options.ts:134

Options of static destroy.

Extends BulkHookOptions. Paranoid models are soft-deleted (deletedAt set) unless force.

Type Parameters ​

T ​

T = Values

Type Declaration ​

cascade? ​

optional cascade?: boolean

With truncate: add CASCADE.

Default Value ​

ts
false

force? ​

optional force?: boolean

For paranoid models: delete rows instead of setting deletedAt.

Default Value ​

ts
false

limit? ​

optional limit?: number

Delete at most this many rows.

restartIdentity? ​

optional restartIdentity?: boolean

With truncate: add RESTART IDENTITY.

Default Value ​

ts
false

returning? ​

optional returning?: boolean

postgrelize extension

Return deleted rows instead of their count (DELETE ... RETURNING). PostgreSQL extension.

truncate? ​

optional truncate?: boolean

Use TRUNCATE instead of DELETE.

Default Value ​

ts
false

using? ​

optional using?: JoinSources

postgrelize extension

Extra relations (DELETE ... USING), keyed by alias. PostgreSQL extension.

where? ​

optional where?: WhereOptions<T>

Rows to delete.

See ​

Model.destroy

Example ​

ts
await Post.destroy({ where: { draft: true }, force: true });
const opts: DestroyOptions<Task> = { truncate: true, cascade: true, restartIdentity: true };

Released under the MIT License.