【问题标题】:Sequelize nested data structureSequelize 嵌套数据结构
【发布时间】:2018-03-16 04:18:32
【问题描述】:

我正在尝试使用 sequelize 和 nodeJS 对我们的 postgresQL 数据库进行查询。

除了模型的深层嵌套关系结构之外,一切都很好。

我的例子:

{
      model: this.Parent,
      as: 'Parent',
      include: [
        {
          model: this.Child,
          as: 'child',
          include: [
            {
              model: this.nestedChild,
              as: 'nestedChild',
            },
          ],
        },
      ],
    },

child 和nestedChild 的数据在'included' 对象中返回,问题是nestedChild 不再在child 的'relationships' 对象中,而是它的参数之一。 示例:

data: [proper array of Parent elements with defined 'child' relationship in 'relationships' object],
included: [
    {
        attributes: {
            nested-child: {
            (here are properties for my nestedChild)
            }
        },
    relationships: <------ this is missing, and should include my nestedChild
    }
]

【问题讨论】:

    标签: node.js postgresql orm sequelize.js


    【解决方案1】:

    原来嵌套关系查询很好。该步骤之后的 JSON 序列化程序没有定义正确的结构,因此一旦将响应发送到前端,它就丢失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-27
      • 2022-01-22
      • 2011-09-27
      • 2020-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多