1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2025-01-01 23:43:04 +09:00
cherrypick/src/server/api/common/getters.ts

19 lines
340 B
TypeScript
Raw Normal View History

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;
}