物理削除系の処理を削除
これらの処理はパフォーマンス的に現実的でないし、すべてのモデルの関係を把握している必要があり保守が困難 論理削除でなんとかする
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import db from '../db/mongodb';
|
||||
import isObjectId from '../misc/is-objectid';
|
||||
|
||||
const Following = db.get<IFollowing>('following');
|
||||
Following.createIndex(['followerId', 'followeeId'], { unique: true });
|
||||
@@ -25,30 +24,3 @@ export type IFollowing = {
|
||||
sharedInbox?: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Followingを物理削除します
|
||||
*/
|
||||
export async function deleteFollowing(following: string | mongo.ObjectID | IFollowing) {
|
||||
let f: IFollowing;
|
||||
|
||||
// Populate
|
||||
if (isObjectId(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
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user