@@ -17,50 +17,50 @@ export interface IFindDataloaderEntityRepository<Entity extends object, D extend
17
17
extends EntityRepository < Entity > {
18
18
readonly dataloader : D ;
19
19
20
- find < Hint extends string = never , Fields extends string = never > (
20
+ find < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
21
21
where : FilterQuery < Entity > ,
22
- options ?: { dataloader : false } & FindOptions < Entity , Hint , Fields > ,
23
- ) : Promise < Array < Loaded < Entity , Hint , Fields > > > ;
24
- find < Hint extends string = never , Fields extends string = never > (
22
+ options ?: { dataloader : false } & FindOptions < Entity , Hint , Fields , Excludes > ,
23
+ ) : Promise < Array < Loaded < Entity , Hint , Fields , Excludes > > > ;
24
+ find < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
25
25
where : FilterQueryDataloader < Entity > ,
26
- options ?: { dataloader : boolean } & Pick < FindOptions < Entity , Hint , Fields > , "populate" > ,
27
- ) : Promise < Array < Loaded < Entity , Hint , Fields > > > ;
28
- find < Hint extends string = never , Fields extends string = never > (
26
+ options ?: { dataloader : boolean } & Pick < FindOptions < Entity , Hint , Fields , Excludes > , "populate" > ,
27
+ ) : Promise < Array < Loaded < Entity , Hint , Fields , Excludes > > > ;
28
+ find < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
29
29
where : D extends true ? FilterQueryDataloader < Entity > : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
30
30
options ?: { dataloader ?: undefined } & ( D extends true
31
- ? Pick < FindOptions < Entity , Hint , Fields > , "populate" >
32
- : FindOptions < Entity , Hint , Fields > ) ,
33
- ) : Promise < Array < Loaded < Entity , Hint , Fields > > > ;
31
+ ? Pick < FindOptions < Entity , Hint , Fields , Excludes > , "populate" >
32
+ : FindOptions < Entity , Hint , Fields , Excludes > ) ,
33
+ ) : Promise < Array < Loaded < Entity , Hint , Fields , Excludes > > > ;
34
34
35
- findOne < Hint extends string = never , Fields extends string = never > (
35
+ findOne < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
36
36
where : FilterQuery < Entity > ,
37
- options ?: { dataloader : false } & FindOneOptions < Entity , Hint , Fields > ,
38
- ) : Promise < Loaded < Entity , Hint , Fields > | null > ;
39
- findOne < Hint extends string = never , Fields extends string = never > (
37
+ options ?: { dataloader : false } & FindOneOptions < Entity , Hint , Fields , Excludes > ,
38
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > | null > ;
39
+ findOne < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
40
40
where : FilterQueryDataloader < Entity > ,
41
- options ?: { dataloader : boolean } & Pick < FindOneOptions < Entity , Hint , Fields > , "populate" > ,
42
- ) : Promise < Loaded < Entity , Hint , Fields > | null > ;
43
- findOne < Hint extends string = never , Fields extends string = never > (
41
+ options ?: { dataloader : boolean } & Pick < FindOneOptions < Entity , Hint , Fields , Excludes > , "populate" > ,
42
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > | null > ;
43
+ findOne < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
44
44
where : D extends true ? FilterQueryDataloader < Entity > : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
45
45
options ?: { dataloader ?: undefined } & ( D extends true
46
- ? Pick < FindOneOptions < Entity , Hint , Fields > , "populate" >
47
- : FindOneOptions < Entity , Hint , Fields > ) ,
48
- ) : Promise < Loaded < Entity , Hint , Fields > | null > ;
46
+ ? Pick < FindOneOptions < Entity , Hint , Fields , Excludes > , "populate" >
47
+ : FindOneOptions < Entity , Hint , Fields , Excludes > ) ,
48
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > | null > ;
49
49
50
- findOneOrFail < Hint extends string = never , Fields extends string = never > (
50
+ findOneOrFail < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
51
51
where : FilterQuery < Entity > ,
52
- options ?: { dataloader : false } & FindOneOrFailOptions < Entity , Hint , Fields > ,
53
- ) : Promise < Loaded < Entity , Hint , Fields > > ;
54
- findOneOrFail < Hint extends string = never , Fields extends string = never > (
52
+ options ?: { dataloader : false } & FindOneOrFailOptions < Entity , Hint , Fields , Excludes > ,
53
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > > ;
54
+ findOneOrFail < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
55
55
where : FilterQueryDataloader < Entity > ,
56
- options ?: { dataloader : boolean } & Pick < FindOneOrFailOptions < Entity , Hint , Fields > , "populate" > ,
57
- ) : Promise < Loaded < Entity , Hint , Fields > > ;
58
- findOneOrFail < Hint extends string = never , Fields extends string = never > (
56
+ options ?: { dataloader : boolean } & Pick < FindOneOrFailOptions < Entity , Hint , Fields , Excludes > , "populate" > ,
57
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > > ;
58
+ findOneOrFail < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
59
59
where : D extends true ? FilterQueryDataloader < Entity > : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
60
60
options ?: { dataloader ?: undefined } & ( D extends true
61
- ? Pick < FindOneOrFailOptions < Entity , Hint , Fields > , "populate" >
62
- : FindOneOrFailOptions < Entity , Hint , Fields > ) ,
63
- ) : Promise < Loaded < Entity , Hint , Fields > > ;
61
+ ? Pick < FindOneOrFailOptions < Entity , Hint , Fields , Excludes > , "populate" >
62
+ : FindOneOrFailOptions < Entity , Hint , Fields , Excludes > ) ,
63
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > > ;
64
64
}
65
65
66
66
export type FindDataloaderEntityRepositoryCtor < Entity extends object , D extends boolean > = new (
@@ -78,13 +78,13 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
78
78
readonly dataloader = defaultEnabled ;
79
79
private readonly findLoader = new DataLoader ( getFindBatchLoadFn ( this . em , this . entityName ) ) ;
80
80
81
- async find < Hint extends string = never , Fields extends string = never > (
81
+ async find < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
82
82
where : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
83
83
options ?: { dataloader ?: boolean } & (
84
- | Pick < FindOptions < Entity , Hint , Fields > , "populate" >
85
- | FindOptions < Entity , Hint , Fields >
84
+ | Pick < FindOptions < Entity , Hint , Fields , Excludes > , "populate" >
85
+ | FindOptions < Entity , Hint , Fields , Excludes >
86
86
) ,
87
- ) : Promise < Array < Loaded < Entity , Hint , Fields > > > {
87
+ ) : Promise < Array < Loaded < Entity , Hint , Fields , Excludes > > > {
88
88
const entityName = Utils . className ( this . entityName ) ;
89
89
const res = await ( options ?. dataloader ?? this . dataloader
90
90
? this . findLoader . load ( {
@@ -94,17 +94,17 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
94
94
options,
95
95
many : true ,
96
96
} )
97
- : this . em . find < Entity , Hint , Fields > ( this . entityName , where as FilterQuery < Entity > , options ) ) ;
98
- return res as Array < Loaded < Entity , Hint , Fields > > ;
97
+ : this . em . find < Entity , Hint , Fields , Excludes > ( this . entityName , where as FilterQuery < Entity > , options ) ) ;
98
+ return res as Array < Loaded < Entity , Hint , Fields , Excludes > > ;
99
99
}
100
100
101
- async findOne < Hint extends string = never , Fields extends string = never > (
101
+ async findOne < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
102
102
where : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
103
103
options ?: { dataloader ?: boolean } & (
104
- | Pick < FindOneOptions < Entity , Hint , Fields > , "populate" >
105
- | FindOneOptions < Entity , Hint , Fields >
104
+ | Pick < FindOneOptions < Entity , Hint , Fields , Excludes > , "populate" >
105
+ | FindOneOptions < Entity , Hint , Fields , Excludes >
106
106
) ,
107
- ) : Promise < Loaded < Entity , Hint , Fields > | null > {
107
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > | null > {
108
108
const entityName = Utils . className ( this . entityName ) ;
109
109
const res = await ( options ?. dataloader ?? this . dataloader
110
110
? this . findLoader . load ( {
@@ -114,17 +114,17 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
114
114
options,
115
115
many : false ,
116
116
} )
117
- : this . em . findOne < Entity , Hint , Fields > ( this . entityName , where as FilterQuery < Entity > , options ) ) ;
118
- return res as Loaded < Entity , Hint , Fields > | null ;
117
+ : this . em . findOne < Entity , Hint , Fields , Excludes > ( this . entityName , where as FilterQuery < Entity > , options ) ) ;
118
+ return res as Loaded < Entity , Hint , Fields , Excludes > | null ;
119
119
}
120
120
121
- async findOneOrFail < Hint extends string = never , Fields extends string = never > (
121
+ async findOneOrFail < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
122
122
where : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
123
123
options ?: { dataloader ?: boolean } & (
124
- | Pick < FindOneOrFailOptions < Entity , Hint , Fields > , "populate" >
125
- | FindOneOrFailOptions < Entity , Hint , Fields >
124
+ | Pick < FindOneOrFailOptions < Entity , Hint , Fields , Excludes > , "populate" >
125
+ | FindOneOrFailOptions < Entity , Hint , Fields , Excludes >
126
126
) ,
127
- ) : Promise < Loaded < Entity , Hint , Fields > > {
127
+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > > {
128
128
const entityName = Utils . className ( this . entityName ) ;
129
129
const res = await ( options ?. dataloader ?? this . dataloader
130
130
? this . findLoader . load ( {
@@ -134,11 +134,15 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
134
134
options,
135
135
many : false ,
136
136
} )
137
- : this . em . findOneOrFail < Entity , Hint , Fields > ( this . entityName , where as FilterQuery < Entity > , options ) ) ;
137
+ : this . em . findOneOrFail < Entity , Hint , Fields , Excludes > (
138
+ this . entityName ,
139
+ where as FilterQuery < Entity > ,
140
+ options ,
141
+ ) ) ;
138
142
if ( res == null ) {
139
143
throw new Error ( "Cannot find result" ) ;
140
144
}
141
- return res as Loaded < Entity , Hint , Fields > ;
145
+ return res as Loaded < Entity , Hint , Fields , Excludes > ;
142
146
}
143
147
}
144
148
0 commit comments