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 b6c9117f
authored
Apr 04, 2019
by
Yaroslav Admin
Committed by
Sushant
Apr 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(types): add basic support for `bind` in sequelize.query() method (#10694)
1 parent
cc765cc8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
types/lib/query-interface.d.ts
types/test/connection.ts
types/lib/query-interface.d.ts
View file @
b6c9117
...
...
@@ -5,6 +5,8 @@ import QueryTypes = require('./query-types');
import
{
Sequelize
,
RetryOptions
}
from
'./sequelize'
;
import
{
Transaction
}
from
'./transaction'
;
type
BindOrReplacements
=
{
[
key
:
string
]:
unknown
}
|
unknown
[];
/**
* Interface for query options
*/
...
...
@@ -40,9 +42,13 @@ export interface QueryOptions extends Logging, Transactionable {
* Either an object of named parameter replacements in the format `:param` or an array of unnamed
* replacements to replace `?` in your SQL.
*/
replacements
?:
{
[
key
:
string
]:
string
|
number
|
string
[]
|
number
[];
}
|
string
[];
replacements
?:
BindOrReplacements
;
/**
* Either an object of named parameter bindings in the format `$param` or an array of unnamed
* values to bind to `$1`, `$2`, etc in your SQL.
*/
bind
?:
BindOrReplacements
;
/**
* Force the query to use the write pool, regardless of the query type.
...
...
types/test/connection.ts
View file @
b6c9117
...
...
@@ -35,4 +35,12 @@ sequelize.transaction<void>(async transaction => {
transaction
,
logging
:
true
,
})
})
});
sequelize
.
query
(
'SELECT * FROM `user` WHERE status = $1'
,
{
bind
:
[
'active'
],
type
:
QueryTypes
.
SELECT
}
);
sequelize
.
query
(
'SELECT * FROM `user` WHERE status = $status'
,
{
bind
:
{
status
:
'active'
},
type
:
QueryTypes
.
SELECT
}
);
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