All files / src/Query Query.js

0% Statements 0/19
0% Branches 0/2
0% Functions 0/9
0% Lines 0/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                                                     
"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