Просмотр исходного кода

ensure /_api/me/user-group-relations to return valid data

Yuki Takei 7 лет назад
Родитель
Сommit
354b0e42cc
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      lib/models/user-group-relation.js

+ 6 - 1
lib/models/user-group-relation.js

@@ -99,7 +99,12 @@ class UserGroupRelation {
     return this
     return this
       .find({ relatedUser: user.id })
       .find({ relatedUser: user.id })
       .populate('relatedGroup')
       .populate('relatedGroup')
-      .exec();
+      // filter documents only relatedGroup is not null
+      .then(userGroupRelations => {
+        return userGroupRelations.filter(relation => {
+          return relation.relatedGroup != null;
+        });
+      });
   }
   }
 
 
   /**
   /**