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

Commit 143cc84c by JacobLey Committed by GitHub

fix(typings): `returning` can specify column names (#13215)

1 parent 8f2a0d52
Showing with 10 additions and 6 deletions
......@@ -719,7 +719,7 @@ export interface UpsertOptions<TAttributes = any> extends Logging, Transactionab
/**
* Return the affected rows (only for postgres)
*/
returning?: boolean;
returning?: boolean | (keyof TAttributes)[];
/**
* Run validations before the row is inserted
......
import {Model} from "sequelize"
import {sequelize} from './connection';
class TestModel extends Model {
class TestModel extends Model<{ foo: string; bar: string }, {}> {
}
TestModel.init({}, {sequelize})
TestModel.init({
foo: '<foo>',
bar: '<bar>',
}, {sequelize})
sequelize.transaction(async trx => {
const res1: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, {
benchmark: true,
fields: ['testField'],
fields: ['foo'],
hooks: true,
logging: true,
returning: true,
......@@ -20,7 +23,7 @@ sequelize.transaction(async trx => {
const res2: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, {
benchmark: true,
fields: ['testField'],
fields: ['foo'],
hooks: true,
logging: true,
returning: false,
......@@ -31,9 +34,10 @@ sequelize.transaction(async trx => {
const res3: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, {
benchmark: true,
fields: ['testField'],
fields: ['foo'],
hooks: true,
logging: true,
returning: ['foo'],
searchPath: 'DEFAULT',
transaction: trx,
validate: true,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!