Initial commit 🍀
This commit is contained in:
commit
b3f42e62af
405 changed files with 31017 additions and 0 deletions
25
src/api/common/get-friends.ts
Normal file
25
src/api/common/get-friends.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import * as mongodb from 'mongodb';
|
||||
import Following from '../models/following';
|
||||
|
||||
export default async (me: mongodb.ObjectID, includeMe: boolean = true) => {
|
||||
// Fetch relation to other users who the I follows
|
||||
// SELECT followee
|
||||
const myfollowing = await Following
|
||||
.find({
|
||||
follower_id: me,
|
||||
// 削除されたドキュメントは除く
|
||||
deleted_at: { $exists: false }
|
||||
}, {
|
||||
followee_id: true
|
||||
})
|
||||
.toArray();
|
||||
|
||||
// ID list of other users who the I follows
|
||||
const myfollowingIds = myfollowing.map(follow => follow.followee_id);
|
||||
|
||||
if (includeMe) {
|
||||
myfollowingIds.push(me);
|
||||
}
|
||||
|
||||
return myfollowingIds;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue