Skip to content

Commit 3e0ea5e

Browse files
closes #61 (fixes type declarations for attributes options)
1 parent 3022a46 commit 3e0ea5e

File tree

3 files changed

+40
-60
lines changed

3 files changed

+40
-60
lines changed

lib/interfaces/IBaseIncludeOptions.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {WhereOptions, IncludeThroughOptions, FindOptionsAttributesArray} from 'sequelize';
2+
3+
/**
4+
* Complex include options
5+
*/
6+
export interface IBaseIncludeOptions {
7+
8+
/**
9+
* The alias of the relation, in case the model you want to eagerly load is aliassed. For `hasOne` /
10+
* `belongsTo`, this should be the singular name, and for `hasMany`, it should be the plural
11+
*/
12+
as?: string;
13+
14+
/**
15+
* Where clauses to apply to the child models. Note that this converts the eager load to an inner join,
16+
* unless you explicitly set `required: false`
17+
*/
18+
where?: WhereOptions;
19+
20+
/**
21+
* A list of attributes to select from the child model
22+
*/
23+
attributes?: FindOptionsAttributesArray | { include?: FindOptionsAttributesArray, exclude?: string[] };
24+
25+
/**
26+
* If true, converts to an inner join, which means that the parent model will only be loaded if it has any
27+
* matching children. True if `include.where` is set, false otherwise.
28+
*/
29+
required?: boolean;
30+
31+
/**
32+
* Through Options
33+
*/
34+
through?: IncludeThroughOptions;
35+
36+
}

lib/interfaces/IIncludeOptions.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,22 @@
1-
import {WhereOptions, IncludeThroughOptions} from 'sequelize';
21
import {Model} from "../models/Model";
32
import {IIncludeAssociation} from "./IIncludeAssociation";
3+
import {IBaseIncludeOptions} from "./IBaseIncludeOptions";
44

55
/**
66
* Complex include options
77
*/
8-
export interface IIncludeOptions {
8+
export interface IIncludeOptions extends IBaseIncludeOptions {
99

1010
/**
1111
* The model you want to eagerly load
1212
*/
1313
model?: typeof Model;
1414

15-
/**
16-
* The alias of the relation, in case the model you want to eagerly load is aliassed. For `hasOne` /
17-
* `belongsTo`, this should be the singular name, and for `hasMany`, it should be the plural
18-
*/
19-
as?: string;
20-
2115
/**
2216
* The association you want to eagerly load. (This can be used instead of providing a model/as pair)
2317
*/
2418
association?: IIncludeAssociation;
2519

26-
/**
27-
* Where clauses to apply to the child models. Note that this converts the eager load to an inner join,
28-
* unless you explicitly set `required: false`
29-
*/
30-
where?: WhereOptions;
31-
32-
/**
33-
* A list of attributes to select from the child model
34-
*/
35-
attributes?: string[];
36-
37-
/**
38-
* If true, converts to an inner join, which means that the parent model will only be loaded if it has any
39-
* matching children. True if `include.where` is set, false otherwise.
40-
*/
41-
required?: boolean;
42-
43-
/**
44-
* Through Options
45-
*/
46-
through?: IncludeThroughOptions;
47-
4820
/**
4921
* Load further nested related models
5022
*/

lib/interfaces/IScopeIncludeOptions.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,22 @@
1-
import {WhereOptions, IncludeThroughOptions} from 'sequelize';
21
import {IScopeIncludeAssociation} from "./IScopeIncludeAssociation";
32
import {ModelClassGetter} from "../types/ModelClassGetter";
3+
import {IBaseIncludeOptions} from "./IBaseIncludeOptions";
44

55
/**
66
* Complex include options
77
*/
8-
export interface IScopeIncludeOptions {
8+
export interface IScopeIncludeOptions extends IBaseIncludeOptions {
99

1010
/**
1111
* The model you want to eagerly load
1212
*/
1313
model?: ModelClassGetter;
1414

15-
/**
16-
* The alias of the relation, in case the model you want to eagerly load is aliassed. For `hasOne` /
17-
* `belongsTo`, this should be the singular name, and for `hasMany`, it should be the plural
18-
*/
19-
as?: string;
20-
2115
/**
2216
* The association you want to eagerly load. (This can be used instead of providing a model/as pair)
2317
*/
2418
association?: IScopeIncludeAssociation;
2519

26-
/**
27-
* Where clauses to apply to the child models. Note that this converts the eager load to an inner join,
28-
* unless you explicitly set `required: false`
29-
*/
30-
where?: WhereOptions;
31-
32-
/**
33-
* A list of attributes to select from the child model
34-
*/
35-
attributes?: string[];
36-
37-
/**
38-
* If true, converts to an inner join, which means that the parent model will only be loaded if it has any
39-
* matching children. True if `include.where` is set, false otherwise.
40-
*/
41-
required?: boolean;
42-
43-
/**
44-
* Through Options
45-
*/
46-
through?: IncludeThroughOptions;
47-
4820
/**
4921
* Load further nested related models
5022
*/

0 commit comments

Comments
 (0)