Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1stack specificStack: Sequelize
databasesequelizecorrectness
Don't set include required:true when a where clause already forces it
In Sequelize, defining a where on an include makes it required automatically; an explicit required:true can wrongly exclude rows (e.g. users with zero relations).
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | include: [{ model: Following, where: { active: true }, required: true }] |
| 2 | // users with 0 followings always get an empty result |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | include: [{ model: Following, where: { active: true } }] // required implied only when filtering |
Explanation (EN)
Objašnjenje (HR)