smaller refactorings (mostly entitization)

This commit is contained in:
azivner
2018-04-01 11:05:09 -04:00
parent c9d73c6115
commit fad0ec757b
12 changed files with 69 additions and 56 deletions

View File

@@ -2,6 +2,7 @@
const Entity = require('./entity');
const repository = require('../services/repository');
const utils = require('../services/utils');
class NoteImage extends Entity {
static get tableName() { return "note_images"; }
@@ -10,6 +11,18 @@ class NoteImage extends Entity {
async getNote() {
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
}
async getImage() {
return await repository.getEntity("SELECT * FROM images WHERE imageId = ?", [this.imageId]);
}
beforeSaving() {
if (!this.dateCreated) {
this.dateCreated = utils.nowDate();
}
this.dateModified = utils.nowDate();
}
}
module.exports = NoteImage;