This commit is contained in:
こぴなたみぽ
2018-04-12 07:19:28 +09:00
parent a015524cb5
commit 991635f919
3 changed files with 40 additions and 1 deletions

View File

@@ -11,3 +11,30 @@ export interface IPollVote {
noteId: mongo.ObjectID;
choice: number;
}
/**
* PollVoteを物理削除します
*/
export async function deletePollVote(pollVote: string | mongo.ObjectID | IPollVote) {
let p: IPollVote;
// Populate
if (mongo.ObjectID.prototype.isPrototypeOf(pollVote)) {
p = await PollVote.findOne({
_id: pollVote
});
} else if (typeof pollVote === 'string') {
p = await PollVote.findOne({
_id: new mongo.ObjectID(pollVote)
});
} else {
p = pollVote as IPollVote;
}
if (p == null) return;
// このPollVoteを削除
await PollVote.remove({
_id: p._id
});
}