mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-01 10:11:31 +08:00
28 lines
705 B
JavaScript
28 lines
705 B
JavaScript
"use strict";
|
|
|
|
const Entity = require('./entity');
|
|
const dateUtils = require('../services/date_utils');
|
|
|
|
class Image extends Entity {
|
|
static get entityName() { return "images"; }
|
|
static get primaryKeyName() { return "imageId"; }
|
|
static get hashedProperties() { return ["imageId", "format", "checksum", "name", "isDeleted", "dateCreated"]; }
|
|
|
|
beforeSaving() {
|
|
if (!this.isDeleted) {
|
|
this.isDeleted = false;
|
|
}
|
|
|
|
if (!this.dateCreated) {
|
|
this.dateCreated = dateUtils.nowDate();
|
|
}
|
|
|
|
super.beforeSaving();
|
|
|
|
if (this.isChanged) {
|
|
this.dateModified = dateUtils.nowDate();
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Image; |