mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
35 lines
916 B
JavaScript
35 lines
916 B
JavaScript
"use strict";
|
|
|
|
const Entity = require('./entity');
|
|
const protected_session = require('../services/protected_session');
|
|
const utils = require('../services/utils');
|
|
const repository = require('../services/repository');
|
|
|
|
class NoteRevision extends Entity {
|
|
static get tableName() { return "note_revisions"; }
|
|
static get primaryKeyName() { return "noteRevisionId"; }
|
|
|
|
constructor(row) {
|
|
super(row);
|
|
|
|
if (this.isProtected) {
|
|
protected_session.decryptNoteRevision(this);
|
|
}
|
|
}
|
|
|
|
async getNote() {
|
|
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
|
|
}
|
|
|
|
beforeSaving() {
|
|
if (!this.noteRevisionId) {
|
|
this.noteRevisionId = utils.newNoteRevisionId();
|
|
}
|
|
|
|
if (this.isProtected) {
|
|
protected_session.encryptNoteRevision(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = NoteRevision; |