@absolute/change-tracker-node-sdk
Version:
ChangeTracker SDK for Node.js
62 lines (53 loc) • 1.33 kB
JavaScript
/**
* Field - Change Tracker field model
* @class
* @public
*/
module.exports = class Field {
/**
* @constructor
* @returns {Field}
* @param {string} name - table name
* @param {any} prevValue - previous field value
* @param {any} nextValue - next field value
**/
constructor(name, prevValue, nextValue) {
/**
* @type {string}
**/
this.f = name;
/**
* @type {string}
**/
this.p = prevValue;
/**
* @type {string}
**/
this.n = nextValue;
}
set name(name) {
this.f = name;
}
get name() {
return this.f;
}
set prevValue(prevValue) {
this.p = prevValue;
}
get prevValue() {
return this.p;
}
set nextValue(nextValue) {
this.n = nextValue;
}
get nextValue() {
return this.n;
}
toString() {
const name = this.f, prev = this.p, next = this.n;
if ((prev + '').toLowerCase() === (next + '').toLowerCase())
return name + '=(' + next + ')';
// modified
return name + '=(' + (typeof prev === undefined ? '' : prev) + ' => ' + (typeof prev === undefined ? '' : next) + ')';
}
}