mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-30 22:07:39 -07:00
26 lines
627 B
TypeScript
26 lines
627 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({
|
|
follower_id: me,
|
|
// 削除されたドキュメントは除く
|
|
deleted_at: { $exists: false }
|
|
}, {
|
|
fields: {
|
|
followee_id: true
|
|
}
|
|
});
|
|
|
|
// ID list of other users who the I follows
|
|
const myfollowingIds = myfollowing.map(follow => follow.followee_id);
|
|
|
|
if (includeMe) {
|
|
myfollowingIds.push(me);
|
|
}
|
|
|
|
return myfollowingIds;
|
|
};
|