wip
This commit is contained in:
parent
9c2f340c1e
commit
0ef280377b
3 changed files with 46 additions and 3 deletions
|
|
@ -49,6 +49,33 @@ export interface INotification {
|
|||
isRead: Boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notificationを物理削除します
|
||||
*/
|
||||
export async function deleteNotification(notification: string | mongo.ObjectID | INotification) {
|
||||
let n: INotification;
|
||||
|
||||
// Populate
|
||||
if (mongo.ObjectID.prototype.isPrototypeOf(notification)) {
|
||||
n = await Notification.findOne({
|
||||
_id: notification
|
||||
});
|
||||
} else if (typeof notification === 'string') {
|
||||
n = await Notification.findOne({
|
||||
_id: new mongo.ObjectID(notification)
|
||||
});
|
||||
} else {
|
||||
n = notification as INotification;
|
||||
}
|
||||
|
||||
if (n == null) return;
|
||||
|
||||
// このNotificationを削除
|
||||
await Notification.remove({
|
||||
_id: n._id
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pack a notification for API response
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue