This commit is contained in:
こぴなたみぽ
2018-04-12 07:13:15 +09:00
parent a5ab80bf02
commit a015524cb5
2 changed files with 34 additions and 1 deletions

View File

@ -11,3 +11,30 @@ export type IFollowing = {
followeeId: mongo.ObjectID;
followerId: mongo.ObjectID;
};
/**
* Followingを物理削除します
*/
export async function deleteFollowing(following: string | mongo.ObjectID | IFollowing) {
let f: IFollowing;
// Populate
if (mongo.ObjectID.prototype.isPrototypeOf(following)) {
f = await Following.findOne({
_id: following
});
} else if (typeof following === 'string') {
f = await Following.findOne({
_id: new mongo.ObjectID(following)
});
} else {
f = following as IFollowing;
}
if (f == null) return;
// このFollowingを削除
await Following.remove({
_id: f._id
});
}