UNPKG

coloquent-test2

Version:

Library for retrieving model objects from a JSON-API, with a fluent syntax inspired by Laravel Eloquent.

35 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Reflection_1 = require("../util/Reflection"); var Relation = /** @class */ (function () { function Relation(relatedType, referringObject, name) { if (referringObject === void 0) { referringObject = null; } if (name === void 0) { name = null; } this.relatedType = relatedType; this.referringObject = referringObject; if (name === null) { name = Reflection_1.Reflection.getNameOfNthMethodOffStackTrace(new Error(), 2); } this.name = name; } Relation.prototype.getType = function () { return this.relatedType; }; Relation.prototype.getReferringObject = function () { if (!this.referringObject) { throw new Error("Referring type not set on this relation. You should define the relation on your model with e.g." + " 'this.hasMany(...)' instead of with 'new ToManyRelation(...)'"); } return this.referringObject; }; Relation.prototype.getName = function () { if (!this.name) { throw new Error("Cannot deduce name of relation. You should define the relation on your model with e.g." + " 'this.hasMany(...)' instead of with 'new ToManyRelation(...)'"); } return this.name; }; return Relation; }()); exports.Relation = Relation; //# sourceMappingURL=Relation.js.map