このクエリの結果をノード var オブジェクト「データ」に取得することは可能ですか? コンソールに正しい console.log(results) が表示されますが、結果がデータ変数に返されません。
var Metric = require('../metric');
var gViews = Object.create(Metric.prototype);
gViews.name = 'g_ref';
gViews.initialData = 0;
gViews.increment = function(results) {
var mongodb = require('mongodb');
var server = new mongodb.Server("127.0.0.1", 27017, {});
new mongodb.Db('xxxx', server, {}).open(function (error, client) {
client.collection('xxxx_1', function(err, collection) {
collection.insert({ref_domain:g}, function(err, docs) {
collection.find({ref_domain: /g/}).count(function(err, results) {
console.log(results);
});
});
});
});
this.data;
};
module.exports = gViews;