@@ -68,36 +68,27 @@ export default class DataLoaders {
6868 * Batching function for resolving entities from their ids
6969 * @param collectionName - collection name to get entities
7070 * @param ids - ids for resolving
71- * @param projection - optional mongo projection to limit returned fields
7271 */
7372 private async batchByIds < T extends { _id : ObjectId } > (
7473 collectionName : string ,
75- ids : ReadonlyArray < string > ,
76- projection ?: Record < string , 0 | 1 >
74+ ids : ReadonlyArray < string >
7775 ) : Promise < ( WithId < T > | null ) [ ] > {
78- return this . batchByField < T , '_id' > (
79- collectionName ,
80- '_id' ,
81- ids . map ( id => new ObjectId ( id ) ) ,
82- projection
83- ) ;
76+ return this . batchByField < T , '_id' > ( collectionName , '_id' , ids . map ( id => new ObjectId ( id ) ) ) ;
8477 }
8578
8679 /**
8780 * Batching function for resolving entities by certain field
8881 * @param collectionName - collection name to get entities
8982 * @param fieldName - field name to resolve
9083 * @param values - values for resolving
91- * @param projection - optional mongo projection to limit returned fields
9284 */
9385 private async batchByField <
9486 T extends Record < string , any > ,
9587 FieldType extends keyof T
9688 > (
9789 collectionName : string ,
9890 fieldName : FieldType ,
99- values : ReadonlyArray < T [ FieldType ] > ,
100- projection ?: Record < string , 0 | 1 >
91+ values : ReadonlyArray < T [ FieldType ] >
10192 ) : Promise < ( WithId < T > | null ) [ ] > {
10293 type Doc = WithId < T > ;
10394 const valuesMap = new Map < string , FieldType > ( ) ;
@@ -108,10 +99,9 @@ export default class DataLoaders {
10899
109100 const queryResult = await this . dbConnection
110101 . collection < T > ( collectionName )
111- . find (
112- { [ fieldName ] : { $in : Array . from ( valuesMap . values ( ) ) } } as any ,
113- projection ? { projection } : { }
114- )
102+ . find ( {
103+ [ fieldName ] : { $in : Array . from ( valuesMap . values ( ) ) } ,
104+ } as any )
115105 . toArray ( ) ;
116106
117107 /**
0 commit comments