mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 12:53:08 +02:00
26 lines
629 B
TypeScript
26 lines
629 B
TypeScript
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({
|
|
followerId: me,
|
|
// 削除されたドキュメントは除く
|
|
deletedAt: { $exists: false }
|
|
}, {
|
|
fields: {
|
|
followeeId: true
|
|
}
|
|
});
|
|
|
|
// ID list of other users who the I follows
|
|
const myfollowingIds = myfollowing.map(follow => follow.followeeId);
|
|
|
|
if (includeMe) {
|
|
myfollowingIds.push(me);
|
|
}
|
|
|
|
return myfollowingIds;
|
|
};
|