/var/www/myprog.com.ua/server/node/objects
Edit: /var/www/myprog.com.ua/server/node/objects/role.js (1600B)
let role_db_fields
module.exports = class Role {
constructor(data) {
this.id = data.id ? data.id : 0
this.name = data.name ? data.name : ''
this.static = data.static ? data.static : 0
this.deleted = data.deleted ? data.deleted : 0
role_db_fields = []
for (let k in this) {
role_db_fields.push(k)
}
this.is_changed = false;
this.role_changes = [];
}
update(data) {
for (let i of role_db_fields) {
this.set(i, data[i])
}
}
get_id() {
return this.id
}
set_id(val) {
this.set('id', parseInt(val))
}
get_name() {
return this.name
}
set_name(val) {
this.set('name', val)
}
get_static() {
return this.static
}
set_static(val) {
this.set('static', parseInt(val))
}
get_deleted() {
return this.deleted
}
set_deleted(val) {
this.set('deleted', parseInt(val))
}
set(key, val) {
if (val !== undefined || val != null) {
if (val != this[key]) {
this[key] = val
this.update_changes(key, val)
}
}
}
get_db_fields() {
return role_db_fields
}
get_changes() {
return this.role_changes
}
reset_changes() {
this.is_changed = false
this.role_changes = []
}
update_changes(key, val) {
if (role_db_fields.includes(key)) {
this.is_changed = true
this.role_changes[key] = val
}
}
}