瀏覽代碼

replace id with name

yusuketk 7 年之前
父節點
當前提交
e898470715
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/server/models/page-tag-relation.js

+ 8 - 1
src/server/models/page-tag-relation.js

@@ -46,7 +46,14 @@ class PageTagRelation {
       .limit(opt.limit);
 
     const tags = await Tag.find({ _id: { $in: list.map((elm) => { return elm._id }) } });
-    return list;
+    const res = list.map((elm) => {
+      const tag = tags.filter((tag) => {
+        return (tag.id === String(elm._id));
+      });
+      const name = tag[0].name;
+      return { name, count: elm.count };
+    });
+    return res;
   }
 
 }