diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index 58dcc0de0..b0dfd0ab9 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -129,7 +129,7 @@ export class NotesService { * @return {Revision} the first revision of the note */ async getLatestRevision(note: Note): Promise { - return await this.revisionsService.getLatestRevision(note.id); + return await this.revisionsService.getLatestRevision(note); } /** @@ -139,7 +139,7 @@ export class NotesService { * @return {Revision} the last revision of the note */ async getFirstRevision(note: Note): Promise { - return await this.revisionsService.getFirstRevision(note.id); + return await this.revisionsService.getFirstRevision(note); } /** diff --git a/src/revisions/revisions.service.ts b/src/revisions/revisions.service.ts index 63e6402a1..c745da897 100644 --- a/src/revisions/revisions.service.ts +++ b/src/revisions/revisions.service.ts @@ -49,10 +49,10 @@ export class RevisionsService { return revision; } - async getLatestRevision(noteId: string): Promise { + async getLatestRevision(note: Note): Promise { const revision = await this.revisionRepository.findOne({ where: { - note: noteId, + note: note, }, order: { createdAt: 'DESC', @@ -60,22 +60,22 @@ export class RevisionsService { }, }); if (revision === undefined) { - throw new NotInDBError(`Revision for note ${noteId} not found.`); + throw new NotInDBError(`Revision for note ${note.id} not found.`); } return revision; } - async getFirstRevision(noteId: string): Promise { + async getFirstRevision(note: Note): Promise { const revision = await this.revisionRepository.findOne({ where: { - note: noteId, + note: note, }, order: { createdAt: 'ASC', }, }); if (revision === undefined) { - throw new NotInDBError(`Revision for note ${noteId} not found.`); + throw new NotInDBError(`Revision for note ${note.id} not found.`); } return revision; }