"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
class Query {
constructor(build) {
this._segments = [];
const firstExpression = new _1.QueryExpression(this);
build(firstExpression);
}
AddSegment(newSegment) {
this._segments.push(newSegment);
}
toString() {
return this._segments.map((s) => s.toString()).join('');
}
Exec(repository, path, odataParams = {}) {
odataParams.query = this.toString();
return repository.GetODataApi().Fetch({
path,
params: odataParams
})
.map((q) => {
return {
Result: q.d.results.map((c) => repository.HandleLoadedContent(c)),
Count: q.d.__count
};
});
}
}
exports.Query = Query;
class FinializedQuery extends Query {
constructor(build, _repository, _path, _odataParams = {}) {
super(build);
this._repository = _repository;
this._path = _path;
this._odataParams = _odataParams;
}
Exec() {
return super.Exec(this._repository, this._path, this._odataParams);
}
}
exports.FinializedQuery = FinializedQuery;
//# sourceMappingURL=Query.js.map |