@@ -17,50 +17,50 @@ export interface IFindDataloaderEntityRepository<Entity extends object, D extend
1717 extends EntityRepository < Entity > {
1818 readonly dataloader : D ;
1919
20- find < Hint extends string = never , Fields extends string = never > (
20+ find < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
2121 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 > (
2525 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 > (
2929 where : D extends true ? FilterQueryDataloader < Entity > : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
3030 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 > > > ;
3434
35- findOne < Hint extends string = never , Fields extends string = never > (
35+ findOne < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
3636 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 > (
4040 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 > (
4444 where : D extends true ? FilterQueryDataloader < Entity > : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
4545 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 > ;
4949
50- findOneOrFail < Hint extends string = never , Fields extends string = never > (
50+ findOneOrFail < Hint extends string = never , Fields extends string = "*" , Excludes extends string = never > (
5151 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 > (
5555 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 > (
5959 where : D extends true ? FilterQueryDataloader < Entity > : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
6060 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 > > ;
6464}
6565
6666export type FindDataloaderEntityRepositoryCtor < Entity extends object , D extends boolean > = new (
@@ -78,13 +78,13 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
7878 readonly dataloader = defaultEnabled ;
7979 private readonly findLoader = new DataLoader ( getFindBatchLoadFn ( this . em , this . entityName ) ) ;
8080
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 > (
8282 where : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
8383 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 >
8686 ) ,
87- ) : Promise < Array < Loaded < Entity , Hint , Fields > > > {
87+ ) : Promise < Array < Loaded < Entity , Hint , Fields , Excludes > > > {
8888 const entityName = Utils . className ( this . entityName ) ;
8989 const res = await ( options ?. dataloader ?? this . dataloader
9090 ? this . findLoader . load ( {
@@ -94,17 +94,17 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
9494 options,
9595 many : true ,
9696 } )
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 > > ;
9999 }
100100
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 > (
102102 where : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
103103 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 >
106106 ) ,
107- ) : Promise < Loaded < Entity , Hint , Fields > | null > {
107+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > | null > {
108108 const entityName = Utils . className ( this . entityName ) ;
109109 const res = await ( options ?. dataloader ?? this . dataloader
110110 ? this . findLoader . load ( {
@@ -114,17 +114,17 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
114114 options,
115115 many : false ,
116116 } )
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 ;
119119 }
120120
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 > (
122122 where : FilterQueryDataloader < Entity > | FilterQuery < Entity > ,
123123 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 >
126126 ) ,
127- ) : Promise < Loaded < Entity , Hint , Fields > > {
127+ ) : Promise < Loaded < Entity , Hint , Fields , Excludes > > {
128128 const entityName = Utils . className ( this . entityName ) ;
129129 const res = await ( options ?. dataloader ?? this . dataloader
130130 ? this . findLoader . load ( {
@@ -134,11 +134,15 @@ export function getFindDataloaderEntityRepository<Entity extends object, D exten
134134 options,
135135 many : false ,
136136 } )
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+ ) ) ;
138142 if ( res == null ) {
139143 throw new Error ( "Cannot find result" ) ;
140144 }
141- return res as Loaded < Entity , Hint , Fields > ;
145+ return res as Loaded < Entity , Hint , Fields , Excludes > ;
142146 }
143147 }
144148
0 commit comments