【问题标题】:Node Js return null from mongoose collection节点 Js 从 mongoose 集合返回 null
【发布时间】:2021-08-11 21:34:25
【问题描述】:

我在节点 JS 中创建了一个应用程序,我从 mongoose 数据库中获取数据,如下所示

await dataCollection.find({
  type: 'user',
}).sort([['short_order', 1]]).then((results) => {
  console.log(reslts)
});

从 mongodb 返回数据,但有时它返回 null 而没有任何更改(从总共 10 个请求中的 2-3 个返回 null)
还使用 apollo 服务器进行 graphql 查询,其中接收以下集合数据。
请建议我如何解决这个问题。

【问题讨论】:

    标签: node.js mongodb mongoose


    【解决方案1】:

    有一个错字,您应该注意:console.log(reslts)results

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-20
      • 2012-06-15
      • 2015-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-05
      相关资源
      最近更新 更多