mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
36 lines
924 B
JavaScript
36 lines
924 B
JavaScript
"use strict";
|
|
|
|
const Entity = require('./entity');
|
|
const repository = require('../services/repository');
|
|
const utils = require('../services/utils');
|
|
|
|
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.noteImageId) {
|
|
this.noteImageId = utils.newNoteImageId();
|
|
}
|
|
|
|
if (!this.isDeleted) {
|
|
this.isDeleted = false;
|
|
}
|
|
|
|
if (!this.dateCreated) {
|
|
this.dateCreated = utils.nowDate();
|
|
}
|
|
|
|
this.dateModified = utils.nowDate();
|
|
}
|
|
}
|
|
|
|
module.exports = NoteImage; |