converted note revision protection to repository/entities

This commit is contained in:
azivner
2018-03-31 10:51:37 -04:00
parent 088fb00ca9
commit e8a5d0ae16
14 changed files with 99 additions and 98 deletions

View File

@@ -1,13 +1,29 @@
"use strict";
const Entity = require('./entity');
const protected_session = require('../services/protected_session');
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 this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
}
beforeSaving() {
if (this.isProtected) {
protected_session.encryptNoteRevision(this);
}
}
}