chrobject
Version:
Stores chronicles of plain objects as diffs and snapshots
41 lines (40 loc) • 1.02 kB
JavaScript
/**
* Creator: Christian Hotz
* Company: hydra newmedia GmbH
* Date: 11.06.16
*
* Copyright hydra newmedia GmbH
*/
"use strict";
/**
* Imports
*/
var _ = require('lodash');
var Snapshot = (function () {
function Snapshot(obj, entity, creator, timestamp, id) {
this.entity = entity;
this.creator = creator;
this.obj = obj;
this.objId = _.get(obj, this.entity.idPath);
this.timestamp = timestamp;
if (id) {
this.id = id;
}
}
Snapshot.prototype.isEmpty = function () {
return _.isEmpty(this.obj);
};
Snapshot.prototype.setId = function (id) {
this.id = id;
return this;
};
Snapshot.prototype.setObjId = function (objId) {
this.objId = objId;
return this;
};
Snapshot.prototype.clone = function () {
return new Snapshot(this.obj, this.entity, this.creator, this.timestamp, this.id ? this.id : null);
};
return Snapshot;
}());
exports.Snapshot = Snapshot;