2018-04-01 23:05:09 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Entity = require('./entity');
|
2018-04-03 08:46:46 +08:00
|
|
|
const dateUtils = require('../services/date_utils');
|
2018-04-01 23:05:09 +08:00
|
|
|
|
|
|
|
class Image extends Entity {
|
|
|
|
static get tableName() { return "images"; }
|
|
|
|
static get primaryKeyName() { return "imageId"; }
|
2018-05-22 12:15:54 +08:00
|
|
|
static get syncedProperties() { return ["imageId", "format", "checksum", "name", "isDeleted", "dateModified", "dateCreated"]; }
|
2018-04-01 23:05:09 +08:00
|
|
|
|
|
|
|
beforeSaving() {
|
2018-04-03 08:30:00 +08:00
|
|
|
super.beforeSaving();
|
2018-04-02 05:38:24 +08:00
|
|
|
|
|
|
|
if (!this.isDeleted) {
|
|
|
|
this.isDeleted = false;
|
|
|
|
}
|
|
|
|
|
2018-04-01 23:05:09 +08:00
|
|
|
if (!this.dateCreated) {
|
2018-04-03 08:46:46 +08:00
|
|
|
this.dateCreated = dateUtils.nowDate();
|
2018-04-01 23:05:09 +08:00
|
|
|
}
|
|
|
|
|
2018-04-03 08:46:46 +08:00
|
|
|
this.dateModified = dateUtils.nowDate();
|
2018-04-01 23:05:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Image;
|