postgrelize / MergeOptions
Interface: MergeOptions<T> ​
Defined in: src/model/merge-options.ts:62
postgrelize extensionOptions of Model.merge, which runs a MERGE statement. PostgreSQL extension. PostgreSQL 15+ (RETURNING: 17+).
Rows of the model table are the target; source rows or a subquery are the source.
See ​
Example ​
const opts: MergeOptions<Product> = {
source: [{ sku: 'a1', price: 10 }],
on: { sku: col('source.sku') },
whenMatched: { update: { price: col('source.price') } },
whenNotMatched: { insert: true },
};Type Parameters ​
T ​
T
Properties ​
as? ​
readonlyoptionalas?:string
Defined in: src/model/merge-options.ts:67
Alias of the source relation.
Default Value ​
'source'on ​
readonlyon:unknown
Defined in: src/model/merge-options.ts:69
Join condition between target (model alias) and source (col('source.attr')).
source ​
readonlysource:Subquery| readonlyReadonly<Record<string,unknown>>[]
Defined in: src/model/merge-options.ts:64
Source rows (plain objects) or a subquery.
whenMatched? ​
readonlyoptionalwhenMatched?:MergeMatchedAction<T> | readonlyMergeMatchedAction<T>[]
Defined in: src/model/merge-options.ts:71
Actions for matched rows, applied in order.
whenNotMatched? ​
readonlyoptionalwhenNotMatched?:MergeInsertAction<T> | readonlyMergeInsertAction<T>[]
Defined in: src/model/merge-options.ts:73
Actions for source rows without a target row.
whenNotMatchedBySource? ​
readonlyoptionalwhenNotMatchedBySource?:MergeMatchedAction<T> | readonlyMergeMatchedAction<T>[]
Defined in: src/model/merge-options.ts:75
Actions for target rows without a source row (PostgreSQL 17+).