postgrelize / BulkCreateOptions
Type Alias: BulkCreateOptions<T> ​
BulkCreateOptions<
T> =SaveOptions<T> &object
Defined in: src/model/bulk-options.ts:28
Options of bulkCreate.
Extends SaveOptions. Rows are inserted with one INSERT unless individualHooks or include is set. Validation is off by default (unlike create).
Type Parameters ​
T ​
T = Values
Type Declaration ​
conflictAttributes? ​
optionalconflictAttributes?: readonly (keyofT&string)[]
Conflict target attributes for updateOnDuplicate. Default: first unique key, else primary key.
conflictWhere? ​
optionalconflictWhere?:WhereOptions<T>
Predicate of a partial unique index used as conflict target.
ignoreDuplicates? ​
optionalignoreDuplicates?:boolean
Add ON CONFLICT DO NOTHING, skipping rows that violate a unique constraint.
Default Value ​
falseinclude? ​
optionalinclude?:IncludeOption
Create associated rows from nested values (rows are inserted one by one).
individualHooks? ​
optionalindividualHooks?:boolean
Run per-instance create hooks (rows are then inserted one by one, like v6).
Default Value ​
falseonConflict? ​
postgrelize extension
optionalonConflict?:OnConflictOptions<T>
Advanced ON CONFLICT handling; cannot be combined with the options above. PostgreSQL extension.
unnest? ​
postgrelize extension
optionalunnest?:boolean
Insert with one array parameter per column (INSERT … SELECT * FROM unnest($1::type[], …)) instead of one parameter per cell, so batches are not capped by PostgreSQL's 65535 parameters. Every row must provide every column; ARRAY columns and conflict options are not supported. PostgreSQL extension.
Default Value ​
false
@postgrelizeupdateOnDuplicate? ​
optionalupdateOnDuplicate?: readonly (keyofT&string)[]
Attributes updated from the proposed row on conflict (DO UPDATE SET a = EXCLUDED.a).
See ​
Example ​
const rows = [{ email: 'a@example.com', name: 'Ann' }];
await User.bulkCreate(rows, {
updateOnDuplicate: ['name'],
conflictAttributes: ['email'],
transaction,
});
const opts: BulkCreateOptions<User> = { ignoreDuplicates: true };