dbcollection.find(...) 不是函数

dbcollection.find(...) is not a function

我正在尝试使用 MEAN STACK 和 Angular 4 从数据库中获取文档。(我是这项技术的新手)但是我的 router.js 文件出现以下错误。

打字稿:

router.get('/all', (req, res) => {
MongoClient.connect(URL,function(err, client)
{
    if (err) throw err;
    var myDB = client.db('TrainingDb');
    console.log('Connectedddd to MongoDB');
    var dbcollection = myDB.collection("SessionDetails")

    var cursor=dbcollection.find()
              .toArray()(function (err, items){
              res.json(items);
          })
            .catch((err) => {
            sendError(err, res);
           });
})
});

TypeError: dbcollection.find(...).toArray(...) is not a function

我认为 find 方法中的查询参数是必需的。如果你想要集合的所有元素,只需传递一个空对象:

.find({}).toArray(function (err, items){