Notes/src/becca/entities/boption.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-04-30 23:10:25 +02:00
"use strict";
2022-01-10 17:09:20 +01:00
const dateUtils = require('../../services/date_utils');
const AbstractBeccaEntity = require("./abstract_becca_entity");
2021-04-30 23:10:25 +02:00
/**
2023-06-30 11:18:34 +02:00
* Option represents a name-value pair, either directly configurable by the user or some system property.
2022-04-16 00:17:32 +02:00
*
* @extends AbstractBeccaEntity
2021-04-30 23:10:25 +02:00
*/
class BOption extends AbstractBeccaEntity {
2021-04-30 23:10:25 +02:00
static get entityName() { return "options"; }
static get primaryKeyName() { return "name"; }
static get hashedProperties() { return ["name", "value"]; }
constructor(row) {
super();
this.updateFromRow(row);
this.becca.options[this.name] = this;
}
updateFromRow(row) {
/** @type {string} */
2021-04-30 23:10:25 +02:00
this.name = row.name;
/** @type {string} */
2021-04-30 23:10:25 +02:00
this.value = row.value;
/** @type {boolean} */
2021-04-30 23:10:25 +02:00
this.isSynced = !!row.isSynced;
/** @type {string} */
2021-04-30 23:10:25 +02:00
this.utcDateModified = row.utcDateModified;
}
beforeSaving() {
super.beforeSaving();
this.utcDateModified = dateUtils.utcNowDateTime();
}
getPojo() {
return {
name: this.name,
value: this.value,
isSynced: this.isSynced,
utcDateModified: this.utcDateModified
}
2021-04-30 23:10:25 +02:00
}
}
module.exports = BOption;