Procházet zdrojové kódy

replace id with name

yusuketk před 7 roky
rodič
revize
e898470715
1 změnil soubory, kde provedl 8 přidání a 1 odebrání
  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;
   }
 
 }