TypeError:无法读取null MongoDb错误的属性“长度”

时间:2018-07-20 01:19:43

标签: javascript node.js mongodb npm

在查询中获取mongodb错误。这里的错误:

  

TypeError:无法读取null的属性“ length”

代码如下:

// Open a connection with MongoDB

MongoClient.connect(process.env.MONGO_URL, (error, db) => {
  let dbo = db.db('gamblenomore');

//Running a query to find all customers that are in timezone CST.

dbo.collection('customers').find({therapyConfirmation: true, therapyTimeZone: 'CST', therapyDay: { $gt: 0 } }).toArray((error, result) => {
    let max = result.length;
    if (error) {
      throw error;
    }

'customers'中目前没有符合上述条件的文档。

1 个答案:

答案 0 :(得分:0)

将代码更改为:

login.component.ts