UNPKG

3.61 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 if (typeof b !== "function" && b !== null)
11 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12 extendStatics(d, b);
13 function __() { this.constructor = d; }
14 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 };
16})();
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.OneToManyLink = void 0;
19var filter_1 = require("../filter");
20var link_1 = require("./link");
21/**
22 * Represents a one to many relation for OData v4 entities.
23 * For OData v2 entities the [[Link]] is used to represent one to many relation.
24 * See [[Link]] for more information.
25 */
26var OneToManyLink = /** @class */ (function (_super) {
27 __extends(OneToManyLink, _super);
28 function OneToManyLink() {
29 var _this = _super !== null && _super.apply(this, arguments) || this;
30 _this._orderBy = [];
31 return _this;
32 }
33 OneToManyLink.prototype.clone = function () {
34 var clonedLink = _super.prototype.clone.call(this);
35 clonedLink._filters = this._filters;
36 clonedLink._orderBy = this._orderBy;
37 clonedLink._top = this._top;
38 clonedLink._skip = this._skip;
39 return clonedLink;
40 };
41 /**
42 * Create filter statements to be applied to the OData request based on the linked entity values.
43 * @param filters - Filters based on the linked entity.
44 * @returns Newly created `FilterLink`.
45 */
46 OneToManyLink.prototype.filter = function () {
47 var expressions = [];
48 for (var _i = 0; _i < arguments.length; _i++) {
49 expressions[_i] = arguments[_i];
50 }
51 var link = this.clone();
52 link._filters = new filter_1.FilterLink(this, filter_1.toFilterableList(expressions));
53 return link;
54 };
55 /**
56 * Add order-by statements to the request.
57 ** @param orderBy - OrderBy statements to order the response by.
58 * @returns The request builder itself, to facilitate method chaining.
59 */
60 OneToManyLink.prototype.orderBy = function () {
61 var orderBy = [];
62 for (var _i = 0; _i < arguments.length; _i++) {
63 orderBy[_i] = arguments[_i];
64 }
65 var link = this.clone();
66 link._orderBy = orderBy;
67 return link;
68 };
69 /**
70 * Number of returned entities.
71 * @param top - Maximum number of entities to return in the response. Can be less, if less entities match the request.
72 * @returns The request builder itself, to facilitate method chaining.
73 */
74 OneToManyLink.prototype.top = function (top) {
75 var link = this.clone();
76 link._top = top;
77 return link;
78 };
79 /**
80 * Skip number of entities.
81 * @param skip - Number of matching entities to skip. Useful for paging.
82 * @returns The request builder itself, to facilitate method chaining.
83 */
84 OneToManyLink.prototype.skip = function (skip) {
85 var link = this.clone();
86 link._skip = skip;
87 return link;
88 };
89 return OneToManyLink;
90}(link_1.Link));
91exports.OneToManyLink = OneToManyLink;
92//# sourceMappingURL=one-to-many-link.js.map
\No newline at end of file