Sequelize: FindAndCountAll の limit がエラー

imatomix
2017年12月10日 23:18

現象

  • Sequelize で FindAndCountAll する時、以下の条件下だとエラーになる。
  • n:m のリレーションモデルを include するとき
  • これとか
  • これとか
  • ちなみにDBはPostgreSQL

対策

db.projects.findAndCountAll({ subQuery: false, include: [{ model: db.users, // projects と users は n:m }], limit: per_page, offset: per_page * (page - 1) })
  • つまりどういうこと?会社のバックエンドエンジニア兼インフラエンジニアにでも聞いてみようと思う。