This commit is contained in:
Barış Soner Uşaklı
2018-05-10 16:31:16 -04:00
parent 91e6f79f08
commit 3b5d6951bb
8 changed files with 16 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ module.exports = function (db, module) {
{ $group: { _id: null, count: { $sum: 1 } } },
];
db.collection('objects').aggregate(pipeline, function (err, data) {
db.collection('objects').aggregate(pipeline).toArray(function (err, data) {
callback(err, Array.isArray(data) && data.length ? data[0].count : 0);
});
};
@@ -88,7 +88,7 @@ module.exports = function (db, module) {
}
pipeline.push({ $project: project });
db.collection('objects').aggregate(pipeline, function (err, data) {
db.collection('objects').aggregate(pipeline).toArray(function (err, data) {
if (err || !data) {
return callback(err);
}