/var/www/myprog.com.ua/server/node/objects
Edit: /var/www/myprog.com.ua/server/node/objects/event.js (1099B)
//const User = require('./user');
//const microtime = require('../helpers/date');
class Event {
constructor(data) {
// db fields
this.id = 0;
this.device_id = 0;
this.type = '';
this.n = 0;
this.event = '';
this.store = '0';
this.last_date = '';
if (db_fields_names_order.length == 0) {
for (var i in this) {
db_fields_names_order.push(i);
}
}
// set order data from db
if (data) {
for (var i in this) {
if (data[i]) {
this[i] = data[i];
}
}
}
}
get_db_fields_names() {
return db_fields_names_order;
}
get_array() {
let array = [];
this.get_db_fields_names().forEach(k => {
array[k] = this[k];
})
return array;
}
get_json() {
let copy = {};
Object.assign(copy, this.get_array());
return JSON.stringify(copy);
}
}
let db_fields_names_order = [];
module.exports = Event;