Performance: CRUD operations
MEDIUM IMPACT
CRUD operations impact server response time and client rendering speed, affecting how quickly users see and interact with data changes.
async updateUser(id: string, data: UpdateUserDto) { const result = await this.userRepository.update(id, data); if (result.affected === 0) throw new NotFoundException(); return { id, ...data }; }
async updateUser(id: string, data: UpdateUserDto) { const user = await this.userRepository.findOneBy({ id }); if (!user) throw new NotFoundException(); Object.assign(user, data); await this.userRepository.save(user); return user; }
| Pattern | Database Queries | Server Response Time | Client Update Cost | Verdict |
|---|---|---|---|---|
| Fetch then update entity | 2 queries | Higher latency | Moderate | [X] Bad |
| Direct update query | 1 query | Lower latency | Moderate | [OK] Good |