|
|
|
@ -159,32 +159,7 @@ module.exports = function (db, module) {
|
|
|
|
|
if (!Array.isArray(keys) || !keys.length) {
|
|
|
|
|
return callback(null, []);
|
|
|
|
|
}
|
|
|
|
|
var pipeline = [
|
|
|
|
|
{ $match: { _key: { $in: keys } } },
|
|
|
|
|
{ $group: { _id: { _key: '$_key' }, count: { $sum: 1 } } },
|
|
|
|
|
{ $project: { _id: 1, count: '$count' } },
|
|
|
|
|
];
|
|
|
|
|
db.collection('objects').aggregate(pipeline).toArray(function (err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Array.isArray(results)) {
|
|
|
|
|
results = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var map = {};
|
|
|
|
|
results.forEach(function (item) {
|
|
|
|
|
if (item && item._id._key) {
|
|
|
|
|
map[item._id._key] = item.count;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
results = keys.map(function (key) {
|
|
|
|
|
return map[key] || 0;
|
|
|
|
|
});
|
|
|
|
|
callback(null, results);
|
|
|
|
|
});
|
|
|
|
|
async.map(keys, module.sortedSetCard, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.sortedSetRank = function (key, value, callback) {
|
|
|
|
|