物理削除系の処理を削除
これらの処理はパフォーマンス的に現実的でないし、すべてのモデルの関係を把握している必要があり保守が困難 論理削除でなんとかする
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 Blocking = db.get<IBlocking>('blocking');
|
||||
Blocking.createIndex(['blockerId', 'blockeeId'], { unique: true });
|
||||
@@ -12,30 +11,3 @@ export type IBlocking = {
|
||||
blockeeId: mongo.ObjectID;
|
||||
blockerId: mongo.ObjectID;
|
||||
};
|
||||
|
||||
/**
|
||||
* Blockingを物理削除します
|
||||
*/
|
||||
export async function deleteBlocking(blocking: string | mongo.ObjectID | IBlocking) {
|
||||
let f: IBlocking;
|
||||
|
||||
// Populate
|
||||
if (isObjectId(blocking)) {
|
||||
f = await Blocking.findOne({
|
||||
_id: blocking
|
||||
});
|
||||
} else if (typeof blocking === 'string') {
|
||||
f = await Blocking.findOne({
|
||||
_id: new mongo.ObjectID(blocking)
|
||||
});
|
||||
} else {
|
||||
f = blocking as IBlocking;
|
||||
}
|
||||
|
||||
if (f == null) return;
|
||||
|
||||
// このBlockingを削除
|
||||
await Blocking.remove({
|
||||
_id: f._id
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user