Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.__proto__ = proto;
if (proto._id_) {
proto = proto.ns;
if (proto) {
while (proto !== ObjectType) {
proto[id] = this;
proto = getPrototypeOf(proto);
if (proto === Base) break;
}
}
}
// Fix relations proto
getOwnPropertyNames(this).forEach(protoDeep.bind(this, nu));
if (old._id_) remove.call(old._children_, this);
if (nu._id_) {
if (!nu.hasOwnProperty('_children_')) {
defineProperty(nu, '_children_', d('', []));
}
nu._children_.push(this);
}
if (old._id_) old.emit('delete', this);
if (nu._id_) nu.emit('add', this);
}));
if (!nu.prototype) {
// Should never happen, but we better take it easy
// It's result of corrupted database (via e.g. malformed/not-proper import
// messages) or trial of fixing the corrupted database
Plain.prototype.$$proto.call(this, nu);
return;
}
this.__proto__ = nu;
this.prototype.__proto__ = nu.prototype;
// Fix relations proto
getOwnPropertyNames(this).forEach(protoDeep.bind(this, nu));
getOwnPropertyNames(this.prototype)
.forEach(protoDeep.bind(this, nu.prototype));
if (old !== Plain) remove.call(old._children_, this);
if (nu !== Plain) {
if (!nu.hasOwnProperty('_children_')) {
defineProperty(nu, '_children_', d('', []));
}
nu._children_.push(this);
}
if (old !== Plain) old.emit('delete', this, this._id_);
if (nu !== Plain) nu.emit('add', this, this._id_);
}));
module.exports = function self(proto, name) {
var prop, nuProto;
if (!startsWith.call(name, '__') || (name === '__value') ||
!(prop = this[name]) || (this[name] !== this[name.slice(1)])) {
return;
}
nuProto = proto[name] || objProto;
if (prop.__proto__._children_) remove.call(prop.__proto__._children_, prop);
prop.__proto__ = nuProto;
if (nuProto._children_) nuProto._children_.push(prop);
getOwnPropertyNames(prop).forEach(self.bind(prop, proto[name] || objProto));
prop._refresh_();
};
ondelete = function self(obj) {
var rel = obj[name];
if (!rel.hasOwnProperty('_triggersSetup_')) return;
delete rel._triggersSetup_;
remove.call(objects, obj);
obj.off('add', onadd);
obj.off('delete', ondelete);
rel.triggers.forEach(function (triggerName) {
obj['_' + triggerName].off('update', rel._refresh_);
});
if (obj.hasOwnProperty('_children_')) obj._children_.forEach(self);
};
rel.triggers.forEach(function (triggerName) {