mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-29 22:18:07 +09:00
19 lines
340 B
TypeScript
19 lines
340 B
TypeScript
|
import * as mongo from 'mongodb';
|
||
|
import Note from "../../../models/note";
|
||
|
|
||
|
/**
|
||
|
* Get valied note for API processing
|
||
|
*/
|
||
|
export async function getValiedNote(noteId: mongo.ObjectID) {
|
||
|
const note = await Note.findOne({
|
||
|
_id: noteId,
|
||
|
deletedAt: { $exists: false }
|
||
|
});
|
||
|
|
||
|
if (note === null) {
|
||
|
throw 'note not found';
|
||
|
}
|
||
|
|
||
|
return note;
|
||
|
}
|