Notes/src/becca/entities/brecent_note.ts

47 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-05-02 19:59:16 +02:00
"use strict";
import type { RecentNoteRow } from "./rows.js";
import dateUtils from "../../services/date_utils.js";
import AbstractBeccaEntity from "./abstract_becca_entity.js";
2021-05-02 19:59:16 +02:00
/**
* RecentNote represents recently visited note.
*/
class BRecentNote extends AbstractBeccaEntity<BRecentNote> {
2025-01-09 18:07:02 +02:00
static get entityName() {
return "recent_notes";
}
static get primaryKeyName() {
return "noteId";
}
static get hashedProperties() {
return ["noteId", "notePath"];
}
2021-05-02 19:59:16 +02:00
noteId!: string;
notePath!: string;
constructor(row: RecentNoteRow) {
2021-05-02 19:59:16 +02:00
super();
this.updateFromRow(row);
}
updateFromRow(row: RecentNoteRow): void {
2021-05-02 19:59:16 +02:00
this.noteId = row.noteId;
this.notePath = row.notePath;
this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime();
}
getPojo() {
return {
noteId: this.noteId,
notePath: this.notePath,
utcDateCreated: this.utcDateCreated
2025-01-09 18:07:02 +02:00
};
}
2021-05-02 19:59:16 +02:00
}
export default BRecentNote;