From f5a948acaca897fe8fb74c3e9d736d0c6cd50658 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Apr 2018 20:13:04 +0900 Subject: Improve readability --- src/processor/http/deliver-post.ts | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/processor') diff --git a/src/processor/http/deliver-post.ts b/src/processor/http/deliver-post.ts index 1389aede8c..c00ab912c9 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' - } - }, - { + Following.aggregate([{ + $lookup: { + from: 'users', + localField: 'followerId', + foreignField: '_id', + as: 'follower' + } + }, { $match: { - followeeId: post.userId - } + followeeId: post.userId } - ], { + }], { _id: false }) ]).then(([user, followers]) => Promise.all(followers.map(following => { -- cgit v1.2.3-freya