trilium/src/entities/option.js

41 lines
989 B
JavaScript
Raw Normal View History

"use strict";
const Entity = require('./entity');
const dateUtils = require('../services/date_utils');
2018-08-23 05:37:06 +08:00
/**
* Option represents name-value pair, either directly configurable by the user or some system property.
*
2019-11-09 16:36:08 +08:00
* @property {string} name
* @property {string} value
* @property {boolean} isSynced
* @property {string} utcDateModified
* @property {string} utcDateCreated
2018-08-23 05:37:06 +08:00
*
* @extends Entity
*/
class Option extends Entity {
static get entityName() { return "options"; }
2018-06-14 07:10:28 +08:00
static get primaryKeyName() { return "name"; }
static get hashedProperties() { return ["name", "value"]; }
constructor(row) {
super(row);
this.isSynced = !!this.isSynced;
}
beforeSaving() {
if (!this.utcDateCreated) {
this.utcDateCreated = dateUtils.utcNowDateTime();
}
super.beforeSaving();
if (this.isChanged) {
this.utcDateModified = dateUtils.utcNowDateTime();
}
}
}
module.exports = Option;