DataloaderUtils
Index
Constructors
constructor
Returns DataloaderUtils
Methods
staticentitiesAndOptsMapToQueries
Parameters
entitiesAndOptsMap: Map<string, Map<string, Set<any>>>
em: EntityManager<IDatabaseDriver<Connection>>
Returns Promise<[string, any[]]>[]
staticgetColBatchLoadFn
Returns the collection dataloader batchLoadFn, which aggregates collections by entity, makes one query per entity and maps each input collection to the corresponding result.
Parameters
Returns BatchLoadFn<[Collection<any, object>, Omit<InitCollectionOptions<any, any, *, never>, dataloader>?], any>
staticgetColFilter
Creates a filter which returns the results pertaining to a certain collection. First checks if the Entity type matches, then retrieves the inverse side of the relationship where the filtering will be done in order to match the target collection.
Parameters
collection: Collection<any, object>
Returns (result: T) => result is S
Parameters
result: T
Returns result is S
staticgetDataloaderType
Parameters
dataloaderCfg: boolean | DataloaderType
Returns DataloaderType
staticgetRefBatchLoadFn
Returns the reference dataloader batchLoadFn, which aggregates references by entity, makes one query per entity and maps each input reference to the corresponding result.
Parameters
Returns BatchLoadFn<[Reference<any>, Omit<LoadReferenceOptions<any, any, *, never>, dataloader>?], any>
staticgroupInversedOrMappedKeysByEntityAndOpts
Groups collections by entity and returns a Map whose keys are the entity names and whose values are filter Maps which we can use to narrow down the find query to return just the items of the collections that have been dataloaded. The entries of the filter Map will be used as the values of an $or operator so we end up with a query per entity.
Parameters
collsWithOpts: readonly [Collection<any, object>, Omit<InitCollectionOptions<any, any, *, never>, dataloader>?][]
Returns Map<string, Map<string, Set<any>>>
staticgroupPrimaryKeysByEntityAndOpts
Groups identified references by entity and returns a Map with the class name as the index and the corresponding primary keys as the value.
Parameters
refsWithOpts: readonly [Reference<any>, Omit<LoadReferenceOptions<any, any, *, never>, dataloader>?][]
Returns Map<string, Set<any>>
Turn the entity+options map into actual queries. The keys are the entity names + a stringified version of the options and the values are filter Maps which will be used as the values of an $or operator so we end up with a query per entity+opts. We must populate the inverse side of the relationship in order to be able to later retrieve the PK(s) from its item(s). Together with the query the promises will also return the key which can be used to narrow down the results pertaining to a certain set of options.