是否可以将此查询的结果放入节点 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;