不要怂,就是干,撸起袖子干!

Commit 030e0fac by Chocobozzz Committed by Sushant

fix(types): adding upsert with returning: true (#10800)

1 parent 2c06293c
Showing with 30 additions and 3 deletions
......@@ -1919,9 +1919,15 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
public static upsert<M extends Model>(
this: { new (): M } & typeof Model,
values: object,
options?: UpsertOptions
options?: UpsertOptions & { returning?: false | undefined }
): Promise<boolean>;
public static upsert<M extends Model> (
this: { new (): M } & typeof Model,
values: object,
options?: UpsertOptions & { returning: true }
): Promise<[ M, boolean ]>;
/**
* Create and insert multiple instances in bulk.
*
......
......@@ -7,7 +7,7 @@ class TestModel extends Model {
TestModel.init({}, {sequelize})
sequelize.transaction(trx => {
return TestModel.upsert({}, {
TestModel.upsert<TestModel>({}, {
benchmark: true,
fields: ['testField'],
hooks: true,
......@@ -16,5 +16,26 @@ sequelize.transaction(trx => {
searchPath: 'DEFAULT',
transaction: trx,
validate: true,
})
}).then((res: [ TestModel, boolean ]) => {});
TestModel.upsert<TestModel>({}, {
benchmark: true,
fields: ['testField'],
hooks: true,
logging: true,
returning: false,
searchPath: 'DEFAULT',
transaction: trx,
validate: true,
}).then((created: boolean) => {});
return TestModel.upsert<TestModel>({}, {
benchmark: true,
fields: ['testField'],
hooks: true,
logging: true,
searchPath: 'DEFAULT',
transaction: trx,
validate: true,
}).then((created: boolean) => {});
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!