Notes/src/entities/note_image.js

28 lines
747 B
JavaScript
Raw Normal View History

2018-03-31 22:15:06 -04:00
"use strict";
const Entity = require('./entity');
const repository = require('../services/repository');
const utils = require('../services/utils');
2018-03-31 22:15:06 -04:00
class NoteImage extends Entity {
static get tableName() { return "note_images"; }
static get primaryKeyName() { return "noteImageId"; }
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();
}
2018-03-31 22:15:06 -04:00
}
module.exports = NoteImage;