parent
fa07b3023c
commit
22830965e3
6 changed files with 117 additions and 67 deletions
18
src/server/api/common/getters.ts
Normal file
18
src/server/api/common/getters.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue