From f5a948acaca897fe8fb74c3e9d736d0c6cd50658 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Apr 2018 20:13:04 +0900 Subject: [PATCH] Improve readability --- src/processor/http/deliver-post.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/processor/http/deliver-post.ts b/src/processor/http/deliver-post.ts index 1389aede8..c00ab912c 100644 --- a/src/processor/http/deliver-post.ts +++ b/src/processor/http/deliver-post.ts @@ -25,21 +25,18 @@ export default ({ data }) => Post.findOne({ _id: data.id }).then(post => { User.findOne({ _id: post.userId }), // Fetch all followers - Following.aggregate([ - { - $lookup: { - from: 'users', - localField: 'followerId', - foreignField: '_id', - as: 'follower' - } - }, - { - $match: { - followeeId: post.userId - } + Following.aggregate([{ + $lookup: { + from: 'users', + localField: 'followerId', + foreignField: '_id', + as: 'follower' } - ], { + }, { + $match: { + followeeId: post.userId + } + }], { _id: false }) ]).then(([user, followers]) => Promise.all(followers.map(following => {