Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 143cc84c
authored
Jun 25, 2021
by
JacobLey
Committed by
GitHub
Jun 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(typings): `returning` can specify column names (#13215)
1 parent
8f2a0d52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
types/lib/model.d.ts
types/test/upsert.ts
types/lib/model.d.ts
View file @
143cc84
...
...
@@ -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
...
...
types/test/upsert.ts
View file @
143cc84
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
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment