mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: shorter code
This commit is contained in:
@@ -14,13 +14,9 @@ module.exports = function (Categories) {
|
|||||||
if (!Array.isArray(cids) || !cids.length) {
|
if (!Array.isArray(cids) || !cids.length) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
let categories;
|
|
||||||
const keys = cids.map(cid => 'category:' + cid);
|
const keys = cids.map(cid => 'category:' + cid);
|
||||||
if (fields.length) {
|
const categories = await (fields.length ? db.getObjectsFields(keys, fields) : db.getObjects(keys));
|
||||||
categories = await db.getObjectsFields(keys, fields);
|
|
||||||
} else {
|
|
||||||
categories = await db.getObjects(keys);
|
|
||||||
}
|
|
||||||
categories.forEach(category => modifyCategory(category, fields));
|
categories.forEach(category => modifyCategory(category, fields));
|
||||||
return categories;
|
return categories;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user