Node.js 在Sequelize中为引用同一表的列嵌套即时加载不起作用

Node.js 在Sequelize中为引用同一表的列嵌套即时加载不起作用,node.js,postgresql,sequelize.js,Node.js,Postgresql,Sequelize.js,我正在为我的PostgreSQL关系数据库使用SequelizeORM。Sequelize的概念是嵌套的即时加载,如本文所述,这有助于在同一查询中获得给定表的关联 我的DB模式如下 我已经尝试使用本文中提到的嵌套的即时加载,但无法获得ImageProducts表的任何关联 我在ImageProducts表中嵌套的include如下所示: include:[{ model: models.Tags include: [{

我正在为我的
PostgreSQL
关系数据库使用
Sequelize
ORM。Sequelize的概念是
嵌套的即时加载
,如本文所述,这有助于在同一查询中获得给定表的关联

我的
DB模式
如下

我已经尝试使用本文中提到的嵌套的即时加载,但无法获得ImageProducts表的任何关联

我在
ImageProducts
表中嵌套的include如下所示:

 include:[{
            model: models.Tags
            include: [{
                model: models.TagType,
               }],
          }];
   var options = {
        where: {
          //where condition
        },
        options: [{
           model: models.Tags
           include: [{
              model: models.TagType,
               }],
          }]
     }
     models.ImageProducts.findAll(options).then(function (response) {
        if (response.length > 0) {
           //Some Logic
        } else {
           // Some other Logic
        }
     }).catch(function (err) {
          // Error Handling
     });
我的
code
如下:

 include:[{
            model: models.Tags
            include: [{
                model: models.TagType,
               }],
          }];
   var options = {
        where: {
          //where condition
        },
        options: [{
           model: models.Tags
           include: [{
              model: models.TagType,
               }],
          }]
     }
     models.ImageProducts.findAll(options).then(function (response) {
        if (response.length > 0) {
           //Some Logic
        } else {
           // Some other Logic
        }
     }).catch(function (err) {
          // Error Handling
     });
有人能帮我解释一下为什么我不能在我的
ImageProducts
表的sequelize中为
productType
priceRange
列执行
嵌套式快速加载
吗?

它应该是:

var options = {
    where: {
      //where condition
    },
    include: [{                //<- options is not valid
       model: models.Tags
       include: [{
          model: models.TagType,
           }],
      }]
 }
var选项={
其中:{
//何处条件
},
包括:[{/它应该是:

var options = {
    where: {
      //where condition
    },
    include: [{                //<- options is not valid
       model: models.Tags
       include: [{
          model: models.TagType,
           }],
      }]
 }
var选项={
其中:{
//何处条件
},

包括:[{//您应该记得添加一个别名与您在模型中用于关联的别名相同的“as”属性。嗨,Hendrul,我也尝试了此操作,但仍然无法在给定的模型上进行嵌套关联。您应该记得添加一个别名与您在模型中用于关联的别名相同的“as”属性。嗨,Hendrul,我尝试了此操作oo,但仍无法在给定模型上进行嵌套关联。