无法使用Node.js + MongoDB从Azure返回集合

问题描述

我无法以天蓝色更新或获取此收藏集的信息 我肯定在连接字符串和一切正确 我只是无法处理集合the query image click here

Nodejs

 MongoClient.connect(url,{
            useUnifiedTopology: true
            },async function (err,dbs) {
             var dbApp=dbs.db('test'); //the problem in this line 
             dbApp.collection("users").findOne({ userName:Drawer},async function(r,info){
               if(r)throw r;
                  dbApp.collection("users").updateMany({ userName: Drawer },{ $set: { numOfdrawings: info.numOfdrawings+1 },},)
                      await drawings.save();
                      await allDrawings.save();
                      res.json("Painting Added Successfuly !");
                      db.close;
                                                      });
                                                    });
                                                    
                                               
                                               }
                                               
                                          });        

var dbApp = dbs.db('test');中的问题

错误

(node:5637) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'collection' of undefined
at /home/ekko/nodejs/ch_Paintings/src/controller/authController.js:141:65
at /home/ekko/nodejs/ch_Paintings/node_modules/mongoose/lib/model.js:4843:16
at /home/ekko/nodejs/ch_Paintings/node_modules/mongoose/lib/model.js:4843:16
at /home/ekko/nodejs/ch_Paintings/node_modules/mongoose/lib/helpers/promiSEOrCallback.js:24:16
at /home/ekko/nodejs/ch_Paintings/node_modules/mongoose/lib/model.js:4866:21
at /home/ekko/nodejs/ch_Paintings/node_modules/mongoose/lib/query.js:4410:11
at /home/ekko/nodejs/ch_Paintings/node_modules/kareem/index.js:135:16
at processticksAndRejections (internal/process/task_queues.js:79:11)
at runNextTicks (internal/process/task_queues.js:66:3)
at processImmediate (internal/timers.js:429:9)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)