Lazy association returns promise
Review this TypeScript API service method exposing an ORM entity.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1// GET /teams/:id/members
2async function getMembers(teamId: string) {
3 const team = await Team.findByPk(teamId, { include: ['members'] });
4 return team.members.map((m) => ({
5 id: m.id,
6 name: m.name,
7 manager: m.getManager(), // lazy association -> returns a Promise
8 roleLabel: m.role.toUpperCase(),
9 }));
10}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.