Notes/src/entities/note_revision.js

33 lines
946 B
JavaScript
Raw Normal View History

"use strict";
const Entity = require('./entity');
const protectedSessionService = require('../services/protected_session');
const repository = require('../services/repository');
class NoteRevision extends Entity {
2018-01-29 23:35:36 -05:00
static get tableName() { return "note_revisions"; }
2018-01-30 20:12:19 -05:00
static get primaryKeyName() { return "noteRevisionId"; }
2018-05-22 22:22:15 -04:00
static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "content", "dateModifiedFrom", "dateModifiedTo"]; }
2018-01-29 23:35:36 -05:00
constructor(row) {
super(row);
if (this.isProtected) {
protectedSessionService.decryptNoteRevision(this);
}
}
async getNote() {
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
}
beforeSaving() {
2018-04-02 20:30:00 -04:00
super.beforeSaving();
2018-04-01 17:38:24 -04:00
if (this.isProtected) {
protectedSessionService.encryptNoteRevision(this);
}
}
}
module.exports = NoteRevision;