Select Star Over Fetch (ARCH3066)
Ce contenu n’est pas encore disponible dans votre langue.
Key typescript.orm.select-star-over-fetch · Severity info · Category orm
Fetching a full entity/all columns when only a few fields are used downstream increases row width and serialization cost. Use a projection (Select/values/DTO).
Incorrect
Section titled “Incorrect”const users = await userRepo.find(); // all columnsreturn users.map(u => ({ id: u.id, name: u.name }));Correct
Section titled “Correct”const users = await userRepo.find({ select: { id: true, name: true },});return users;Fetch only the needed fields with a select/projection.