because I got bored of customising my CV for every job
at main 20 lines 637 B view raw
1import { BaseDataLoaderService } from "@cv/system"; 2import { Injectable, Scope } from "@nestjs/common"; 3import { CVService } from "./cv.service"; 4import { CV } from "./graphql/cv.type"; 5 6@Injectable({ scope: Scope.REQUEST }) 7export class CVDataLoaderService extends BaseDataLoaderService<string, CV> { 8 constructor(readonly cvService: CVService) { 9 super(async (ids: readonly string[]) => { 10 const cvs = await cvService.findMany({ id: [...ids] }); 11 12 const cvMap = new Map<string, CV>(); 13 for (const cv of cvs) { 14 cvMap.set(cv.id, cv); 15 } 16 17 return ids.map((id) => cvMap.get(id) ?? null); 18 }); 19 } 20}