topics data refactor

This commit is contained in:
Barış Soner Uşaklı
2018-10-20 16:10:02 -04:00
parent 2ee964caa2
commit b2b33ffa57
5 changed files with 79 additions and 91 deletions

View File

@@ -108,7 +108,11 @@ module.exports = function (db, module) {
return getFromCache();
}
db.collection('objects').find({ _key: { $in: nonCachedKeys } }, { projection: { _id: 0 } }).toArray(function (err, data) {
var query = { _key: { $in: nonCachedKeys } };
if (nonCachedKeys.length === 1) {
query._key = nonCachedKeys[0];
}
db.collection('objects').find(query, { projection: { _id: 0 } }).toArray(function (err, data) {
if (err) {
return callback(err);
}