簡體   English   中英

在nodejs collection.find()中沒有從Mongodb集合中獲取值,它什么也不返回

[英]In nodejs collection.find() is not fetching values from Mongodb collection.It returning nothing

 app.get('/render', function(req, res) { MongoClient.connect(dburl, function(err, db) { if (err) throw err; var collection = db.collection('shopping_list'); collection.find().toArray(function(err, result) { res.send({result :result}); }); db.close(); }); }); 
在nodejs集合中,find()不會從Mongodb集合中獲取值。不返回任何內容在nodejs集合中.find()不會從Mongodb集合中獲取值。

exports.index = function(req, res) {
var queryObj = {};
UserModel.find(queryObj)
.exec(function(err, users) {
    if (!users) {
        console.log("users not found");
    }
    if (!err) {
        console.log("number of users",users.length);
    } else {
        console.log("err",err);
    }
});

};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM