feat(note): add version attribute

This attribute was defined in the dev docs,
but never implemented.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-02-13 17:48:38 +01:00
parent 6944094b9b
commit 50c8f39c0c
3 changed files with 11 additions and 0 deletions

View file

@ -67,6 +67,10 @@ export class NoteMetadataDto extends BaseDto {
@ApiProperty() @ApiProperty()
tags: string[]; tags: string[];
@IsNumber()
@ApiProperty()
version: number;
/** /**
* Datestring of the last time this note was updated * Datestring of the last time this note was updated
* @example "2020-12-01 12:23:34" * @example "2020-12-01 12:23:34"

View file

@ -89,6 +89,11 @@ export class Note {
@JoinTable() @JoinTable()
tags: Promise<Tag[]>; tags: Promise<Tag[]>;
@Column({
default: 2,
})
version: number;
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
private constructor() {} private constructor() {}
@ -113,6 +118,7 @@ export class Note {
newNote.description = null; newNote.description = null;
newNote.title = null; newNote.title = null;
newNote.tags = Promise.resolve([]); newNote.tags = Promise.resolve([]);
newNote.version = 2;
return newNote; return newNote;
} }
} }

View file

@ -406,6 +406,7 @@ export class NotesService {
editedBy: (await this.getAuthorUsers(note)).map((user) => user.username), editedBy: (await this.getAuthorUsers(note)).map((user) => user.username),
permissions: await this.toNotePermissionsDto(note), permissions: await this.toNotePermissionsDto(note),
tags: await this.toTagList(note), tags: await this.toTagList(note),
version: note.version,
updatedAt: (await this.getLatestRevision(note)).createdAt, updatedAt: (await this.getLatestRevision(note)).createdAt,
updateUsername: updateUser ? updateUser.username : null, updateUsername: updateUser ? updateUser.username : null,
viewCount: note.viewCount, viewCount: note.viewCount,