@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
50 lines • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OneToOneLink = void 0;
const order_1 = require("../order");
const filter_1 = require("../filter");
const 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.
*/
class OneToOneLink extends link_1.Link {
constructor() {
super(...arguments);
/**
* List of criteria of the linked entity to order the given entity by with descending priority.
*/
this.orderBys = [];
}
clone() {
const clonedLink = super.clone();
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.
*/
orderBy(...orderBy) {
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 {@link FilterLink}.
*/
filter(...filters) {
return new filter_1.FilterLink(this, filters);
}
}
exports.OneToOneLink = OneToOneLink;
//# sourceMappingURL=one-to-one-link.js.map