@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
91 lines • 3.78 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OneToOneLink = void 0;
var filter_1 = require("../filter");
var order_1 = require("../order");
var link_1 = require("./link");
/**
* Represents a link from one entity to one other linked entity (as opposed to a list of linked entities). In OData v2 a `OneToOneLink` can be used to filter and order a selection on an entity based on filters and orders on a linked entity.
* @typeparam EntityT - Type of the entity to be linked from
* @typeparam LinkedEntityT - Type of the entity to be linked to
*/
var OneToOneLink = /** @class */ (function (_super) {
__extends(OneToOneLink, _super);
function OneToOneLink() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* List of criteria of the linked entity to order the given entity by with descending priority.
*/
_this.orderBys = [];
return _this;
}
/**
* @deprecated Since v1.21.0. Use [[clone]] instead.
* Create a new one to one link based on a given link.
* @typeparam EntityT - Type of the entity to be linked from
* @typeparam LinkedEntityT - Type of the entity to be linked to
* @param link - Link to be cloned
* @returns Newly created link
*/
OneToOneLink.clone = function (link) {
var clonedLink = link.clone();
clonedLink.orderBys = link.orderBys;
clonedLink.filters = link.filters;
return clonedLink;
};
OneToOneLink.prototype.clone = function () {
var clonedLink = _super.prototype.clone.call(this);
clonedLink.filters = this.filters;
clonedLink.orderBys = this.orderBys;
return clonedLink;
};
/**
* Create order statements for the OData request based on the linked entity. The given statements have descending priority.
*
* Example:
* ```
* Entity.requestBuilder()
* .getAll()
* .orderBy(Entity.TO_LINKED_ENTITY.orderBy(asc(LinkedEntity.PROPERTY1), desc(LinkedEntity.PROPERTY2)));
* ```
* @param orderBy - Criteria to order by
* @returns Newly created order link
*/
OneToOneLink.prototype.orderBy = function () {
var orderBy = [];
for (var _i = 0; _i < arguments.length; _i++) {
orderBy[_i] = arguments[_i];
}
return new order_1.OrderLink(this, orderBy);
};
/**
* Create filter statements to be applied to the OData request based on the linked entity values.
* @param filters - Filters based on the linked entity.
* @returns Newly created [[FilterLink]].
*/
OneToOneLink.prototype.filter = function () {
var filters = [];
for (var _i = 0; _i < arguments.length; _i++) {
filters[_i] = arguments[_i];
}
return new filter_1.FilterLink(this, filters);
};
return OneToOneLink;
}(link_1.Link));
exports.OneToOneLink = OneToOneLink;
//# sourceMappingURL=one-to-one-link.js.map
;