相关疑难解决方法(0)

Limit and offset in association with include in sequelize

I have 2 models Country, City.

They are associated with each other. City Belongs to Country. Now what I want to do is get cities list within a country query along with limit and offset for pagination if possible.

If i do below it will list all cities within a country. What I need to do is be able to limit cities with limit and offset params.

Country.findById(1, {
  include: [
    { 
      model: City,
      as: 'cities'
    }
  ]
});
Run Code Online (Sandbox Code Playgroud)

Country …

sequelize.js

5
推荐指数
1
解决办法
9896
查看次数

标签 统计

sequelize.js ×1