Node.js Can';t使用nodejs+;数据库
我无法在azure中更新或获取此集合的信息 我确信连接字符串和每件事情都是正确的 我就是不能处理这些收集 Nodejs var dbApp=dbs.db('test')中的问题强> 错误Node.js Can';t使用nodejs+;数据库,node.js,mongodb,azure,mongodb-query,nodejs-server,Node.js,Mongodb,Azure,Mongodb Query,Nodejs Server,我无法在azure中更新或获取此集合的信息 我确信连接字符串和每件事情都是正确的 我就是不能处理这些收集 Nodejs var dbApp=dbs.db('test')中的问题 错误 连接的初始调用中是否有错误?使用哪个sdk? MongoClient.connect(url, { useUnifiedTopology: true },async function (err, dbs) { var dbApp=dbs.d
连接的初始调用中是否有错误?使用哪个sdk?
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;
});
});
}
});
(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)