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 365d7c35
authored
Jan 19, 2020
by
Pedro Augusto de Paula Barbosa
Committed by
Sushant
Jan 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(typings): queryInterface.addIndex (#11844)
1 parent
fbd19d98
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletions
types/lib/query-interface.d.ts
types/test/query-interface.ts
types/type-helpers/set-required.d.ts
types/lib/query-interface.d.ts
View file @
365d7c3
...
...
@@ -4,6 +4,7 @@ import { Promise } from './promise';
import
QueryTypes
=
require
(
'./query-types'
);
import
{
Sequelize
,
RetryOptions
}
from
'./sequelize'
;
import
{
Transaction
}
from
'./transaction'
;
import
{
SetRequired
}
from
'./../type-helpers/set-required'
;
type
BindOrReplacements
=
{
[
key
:
string
]:
unknown
}
|
unknown
[];
type
FieldMap
=
{
[
key
:
string
]:
string
};
...
...
@@ -403,7 +404,7 @@ export class QueryInterface {
):
Promise
<
void
>
;
public
addIndex
(
tableName
:
string
,
options
:
QueryInterfaceIndexOptions
&
{
fields
:
string
[]
}
,
options
:
SetRequired
<
QueryInterfaceIndexOptions
,
'fields'
>
,
rawTablename
?:
string
):
Promise
<
void
>
;
...
...
types/test/query-interface.ts
View file @
365d7c3
...
...
@@ -145,6 +145,15 @@ queryInterface.addIndex('Person', ['firstname', 'lastname'], {
type
:
'UNIQUE'
,
});
queryInterface
.
addIndex
(
'Foo'
,
{
name
:
'foo_a'
,
fields
:
[
{
name
:
'foo_b'
,
order
:
'DESC'
},
'foo_c'
,
{
name
:
'foo_d'
,
order
:
'ASC'
,
collate
:
'foobar'
,
length
:
42
}
],
});
queryInterface
.
removeIndex
(
'Person'
,
'SuperDuperIndex'
);
// or
...
...
types/type-helpers/set-required.d.ts
0 → 100644
View file @
365d7c3
/**
* Full credits to sindresorhus/type-fest
*
* https://github.com/sindresorhus/type-fest/blob/v0.8.1/source/set-required.d.ts
*
* Thank you!
*/
export
type
SetRequired
<
BaseType
,
Keys
extends
keyof
BaseType
=
keyof
BaseType
>
=
// Pick just the keys that are not required from the base type.
Pick
<
BaseType
,
Exclude
<
keyof
BaseType
,
Keys
>>
&
// Pick the keys that should be required from the base type and make them required.
Required
<
Pick
<
BaseType
,
Keys
>>
extends
// If `InferredType` extends the previous, then for each key, use the inferred type key.
infer
InferredType
?
{[
KeyType
in
keyof
InferredType
]:
InferredType
[
KeyType
]}
:
never
;
\ No newline at end of file
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