2021-05-02 19:59:16 +02:00
|
|
|
"use strict";
|
|
|
|
|
2025-01-09 18:36:24 +02:00
|
|
|
import type { RecentNoteRow } from "./rows.js";
|
2024-02-17 00:44:44 +02:00
|
|
|
|
2024-07-18 21:35:17 +03:00
|
|
|
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.
|
|
|
|
*/
|
2024-02-17 11:13:53 +02:00
|
|
|
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
|
|
|
|
2024-03-30 11:09:45 +02:00
|
|
|
noteId!: string;
|
|
|
|
notePath!: string;
|
2024-02-17 00:44:44 +02:00
|
|
|
|
|
|
|
constructor(row: RecentNoteRow) {
|
2021-05-02 19:59:16 +02:00
|
|
|
super();
|
|
|
|
|
2024-03-30 11:09:45 +02:00
|
|
|
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();
|
|
|
|
}
|
2021-05-08 22:13:08 +02:00
|
|
|
|
|
|
|
getPojo() {
|
|
|
|
return {
|
|
|
|
noteId: this.noteId,
|
|
|
|
notePath: this.notePath,
|
|
|
|
utcDateCreated: this.utcDateCreated
|
2025-01-09 18:07:02 +02:00
|
|
|
};
|
2021-05-08 22:13:08 +02:00
|
|
|
}
|
2021-05-02 19:59:16 +02:00
|
|
|
}
|
|
|
|
|
2024-07-18 21:50:12 +03:00
|
|
|
export default BRecentNote;
|