diff --git a/src/notes/note-metadata.dto.ts b/src/notes/note-metadata.dto.ts index a7b0db66e..21d0de6a8 100644 --- a/src/notes/note-metadata.dto.ts +++ b/src/notes/note-metadata.dto.ts @@ -67,6 +67,10 @@ export class NoteMetadataDto extends BaseDto { @ApiProperty() tags: string[]; + @IsNumber() + @ApiProperty() + version: number; + /** * Datestring of the last time this note was updated * @example "2020-12-01 12:23:34" diff --git a/src/notes/note.entity.ts b/src/notes/note.entity.ts index f099c2820..a1183e510 100644 --- a/src/notes/note.entity.ts +++ b/src/notes/note.entity.ts @@ -89,6 +89,11 @@ export class Note { @JoinTable() tags: Promise; + @Column({ + default: 2, + }) + version: number; + // eslint-disable-next-line @typescript-eslint/no-empty-function private constructor() {} @@ -113,6 +118,7 @@ export class Note { newNote.description = null; newNote.title = null; newNote.tags = Promise.resolve([]); + newNote.version = 2; return newNote; } } diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index f1cf658d8..8564a2d14 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -406,6 +406,7 @@ export class NotesService { editedBy: (await this.getAuthorUsers(note)).map((user) => user.username), permissions: await this.toNotePermissionsDto(note), tags: await this.toTagList(note), + version: note.version, updatedAt: (await this.getLatestRevision(note)).createdAt, updateUsername: updateUser ? updateUser.username : null, viewCount: note.viewCount,