MongoDB的find()可以返回不同的logging?
这是一种调用MongoDB
find()
方法,并获得不同的logging? 或者我应该循环结果集?
collection.find({ 'recordType' : recordType, 'date' : { $gte : new Date(dateFrom) }, 'operation' : 'delete' }, { fields : { 'date' : 0, 'operation' : 0 } }).toArray(function (err, results) { jsonResult.push(results); response.write(JSON.stringify(jsonResult)); response.end() });
“collection.find”没有区别。 您可能需要分开使用不同的。 但是,您可以在下面的选项中包含过滤条件。
distinct(key[, query][, options], callback)
例:
testMethod – 这个字段的不同值; 构build – 是过滤标准
collection.distinct('testMethod', {'build':1}, function(err, item) { console.log("item:" + JSON.stringify(item)); db.close(); });