Mongo DB のコレクションからレコードの値を取得しようとしています
これが私の情報源です。
exports.procc = function(req, res) {
db.collection('search', function(err, collection) {
collection.count({'str':'car'},function(err, count) {
console.log(count+' records');//Prints 2 records
c=count;
});
});
console.log('records= '+c);//print 0 records
res.end();
};
問題は、コールバックからレジスタの番号が出力されることですが、コールバックからは 0 が出力され、その値を変数に保存する方法がわかりません。