按顺序在嵌套的加载中继续不工作

我有四个型号的Tehsil,Ilr,Patwar和Villages。 和他们的联系是

Tehsil – > 1:m – > Ilr – > 1:m – > Patwar – > 1:m – >村庄

我想要在我所有的四个模型上应用顺序。

查询:

var tehsilQuery = { include: [{ model: Ilr, as: 'GirdawariKanoongo', include: [{ model: Patwar, as: 'GirdawariPatwar', include: [{ model: Villages, as: 'GirdawariVillages', }] }] }], order: [ ['tehsil_name', 'ASC'], [ {model: Ilr, as: 'GirdawariKanoongo'}, 'kanoongo_name', 'ASC'], [ {model: Patwar, as: 'GirdawariPatwar'}, 'patwar_area', 'ASC'], [ {model: Villages, as: 'GirdawariVillages'}, 'village_name', 'ASC'], ] }; return Tehsils.findAll(tehsilQuery); [Error: 'girdawari_patwar' in order / group clause is not valid association] 

如果我从order删除了PatwarVillages (lat两个模型), order by正在工作。

  • Sequelize获取请求数据的钩子?
  • 有人可以帮我删除我的Db Sequelizelogging吗?
  • NodeJS中的后缀:内部JOIN实现失败
  • Sequelize hasMany通过另一个表
  • 从表中select最新的数据
  • Sequelize.js外键
  • Sequelize.js:查询没有关系的对象
  • Sequelize WHERE sequelize.fn(...)和东西='东西'订购问题
  • 我解决了它。 以下是order外观:

     order: [ 'tehsil_name', 'GirdawariKanoongo.kanoongo_name', 'GirdawariKanoongo.GirdawariPatwar.patwar_area', 'GirdawariKanoongo.GirdawariPatwar.GirdawariVillages.village_name' ] 

    我所要做的就是:使用as关联表并链接它们,然后按column_name应用该order

    另一个嵌套sorting的例子:

     order: [ [ { model: chapterModel, as: 'Chapters' }, 'createdAt', 'ASC'], [ { model: chapterModel, as: 'Chapters' }, { model: partModel, as: 'Parts' }, 'createdAt', 'ASC'] ], 

    部分和章节有M:1的关系。