🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

Total XP: 0|💻 backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Exposing a generic query() method or accepting raw ORM query objects through the repository interface

// Wrong: leaks the abstraction right back out userRepository.query("SELECT * FROM users WHERE active = ?", [true]); // Correct: domain-meaningful, opaque to the caller userRepository.findActive();

The Solution //

This leaks the underlying database/ORM abstraction right back through the interface that was supposed to hide it, defeating the entire purpose of introducing a repository. A well-designed repository exposes only domain-meaningful, specific methods like findActive() or findByEmail(), never a generic pass-through for arbitrary queries.

The Error //

Scattering direct ORM calls (User.findAll(), etc.) throughout business logic instead of behind a repository

// Wrong: business logic tightly coupled to Sequelize directly async function getVipCustomers() { return User.findAll({ where: { tier: "vip" } }); // Sequelize-specific } // Correct: depends on the repository abstraction async function getVipCustomers(userRepository) { return userRepository.findByTier("vip"); }

The Solution //

This tightly couples business logic to a specific ORM and its query API, making the logic hard to unit test in isolation and hard to migrate if the persistence technology ever changes. Introduce a repository interface and have business logic depend on it instead of the ORM directly.

Continue Learning