ravendb
Version:
RavenDB client for Node.js
63 lines • 2.28 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LazyAggregationQueryOperation = void 0;
const IndexQuery_js_1 = require("../../../Queries/IndexQuery.js");
const GetRequest_js_1 = require("../../../Commands/MultiGet/GetRequest.js");
const FacetQueryCommand_js_1 = require("../../../Commands/FacetQueryCommand.js");
const StreamUtil_js_1 = require("../../../../Utility/StreamUtil.js");
class LazyAggregationQueryOperation {
_session;
_indexQuery;
_parent;
_processResults;
constructor(session, indexQuery, parent, processResults) {
this._session = session;
this._indexQuery = indexQuery;
this._processResults = processResults;
this._parent = parent;
}
createRequest() {
const request = new GetRequest_js_1.GetRequest();
request.url = "/queries";
request.method = "POST";
request.query = "?queryHash=" + this._indexQuery.getQueryHash(this._session.conventions.objectMapper);
request.body = (0, IndexQuery_js_1.writeIndexQuery)(this._session.conventions, this._indexQuery);
return request;
}
_result;
_queryResult;
_requiresRetry;
get result() {
return this._result;
}
set result(result) {
this._result = result;
}
get queryResult() {
return this._queryResult;
}
set queryResult(queryResult) {
this._queryResult = queryResult;
}
get requiresRetry() {
return this._requiresRetry;
}
set requiresRetry(result) {
this._requiresRetry = result;
}
async handleResponseAsync(response) {
if (response.forceRetry) {
this._result = null;
this._requiresRetry = true;
return;
}
const result = await FacetQueryCommand_js_1.FacetQueryCommand.parseQueryResultResponseAsync((0, StreamUtil_js_1.stringToReadable)(response.result), this._session.conventions, false);
this._handleResponse(result);
}
_handleResponse(queryResult) {
this.result = this._processResults(queryResult);
this.queryResult = queryResult;
}
}
exports.LazyAggregationQueryOperation = LazyAggregationQueryOperation;
//# sourceMappingURL=LazyAggregationQueryOperation.js.map