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 030e0fac
authored
Apr 22, 2019
by
Chocobozzz
Committed by
Sushant
Apr 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(types): adding upsert with returning: true (#10800)
1 parent
2c06293c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
types/lib/model.d.ts
types/test/upsert.ts
types/lib/model.d.ts
View file @
030e0fa
...
@@ -1919,9 +1919,15 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
...
@@ -1919,9 +1919,15 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
public
static
upsert
<
M
extends
Model
>
(
public
static
upsert
<
M
extends
Model
>
(
this
:
{
new
():
M
}
&
typeof
Model
,
this
:
{
new
():
M
}
&
typeof
Model
,
values
:
object
,
values
:
object
,
options
?:
UpsertOptions
options
?:
UpsertOptions
&
{
returning
?:
false
|
undefined
}
):
Promise
<
boolean
>
;
):
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.
* Create and insert multiple instances in bulk.
*
*
...
...
types/test/upsert.ts
View file @
030e0fa
...
@@ -7,7 +7,7 @@ class TestModel extends Model {
...
@@ -7,7 +7,7 @@ class TestModel extends Model {
TestModel
.
init
({},
{
sequelize
})
TestModel
.
init
({},
{
sequelize
})
sequelize
.
transaction
(
trx
=>
{
sequelize
.
transaction
(
trx
=>
{
return
TestModel
.
upsert
({},
{
TestModel
.
upsert
<
TestModel
>
({},
{
benchmark
:
true
,
benchmark
:
true
,
fields
:
[
'testField'
],
fields
:
[
'testField'
],
hooks
:
true
,
hooks
:
true
,
...
@@ -16,5 +16,26 @@ sequelize.transaction(trx => {
...
@@ -16,5 +16,26 @@ sequelize.transaction(trx => {
searchPath
:
'DEFAULT'
,
searchPath
:
'DEFAULT'
,
transaction
:
trx
,
transaction
:
trx
,
validate
:
true
,
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
)
=>
{});
})
})
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