繁体   English   中英

Sequelize-Promise。所有未定义的返回数组

[英]Sequelize - Promise.All returning array of undefined

以下查询成功注销了查询的结果:

    loans.findAll({
        attributes: option.LoanAttributes,
        include: option.LoanIncludes
      }).then(results => {
      console.log(ExtractQuery(results));
    });

但是,当我将其包装在promise.all函数中时,它将返回未定义的数组:

    Promise.all([
      loans.findAll({
        attributes: option.LoanAttributes,
        include: option.LoanIncludes
      })
    ]).then(results => {
      console.log(ExtractQuery(results));
    })

Promise.all(promiseArraySizeN).then(fulfilledPromiseArraySizeN)

您有一个大小为1的promise数组,因此它将返回一个大小为1的已实现的promise数组。因此,您需要检查result [0]。

Promise.all([
  loans.findAll({
    attributes: option.LoanAttributes,
    include: option.LoanIncludes
  })
]).then(results => {
  console.log(ExtractQuery(results[0]))
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM