Can't return collection from azure by using nodejs + mongodb

48 views Asked by At

i cant update or get the info for this collection in azure iam sure in the connection string and every thing right i just cant deal with the collection 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;
                                                      });
                                                    });
                                                    
                                               
                                               }
                                               
                                          });        

the problem in var dbApp=dbs.db('test');

the error

(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)
0

There are 0 answers