mirror of
https://github.com/zadam/trilium.git
synced 2025-12-21 23:59:59 +01:00
smaller refactorings (mostly entitization)
This commit is contained in:
19
src/entities/image.js
Normal file
19
src/entities/image.js
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const Entity = require('./entity');
|
||||
const utils = require('../services/utils');
|
||||
|
||||
class Image extends Entity {
|
||||
static get tableName() { return "images"; }
|
||||
static get primaryKeyName() { return "imageId"; }
|
||||
|
||||
beforeSaving() {
|
||||
if (!this.dateCreated) {
|
||||
this.dateCreated = utils.nowDate();
|
||||
}
|
||||
|
||||
this.dateModified = utils.nowDate();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Image;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user