ravendb
Version:
RavenDB client for Node.js
64 lines • 2.39 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LazySuggestionQueryOperation = void 0;
const GetRequest_js_1 = require("../../../Commands/MultiGet/GetRequest.js");
const QueryCommand_js_1 = require("../../../Commands/QueryCommand.js");
const StreamUtil_js_1 = require("../../../../Utility/StreamUtil.js");
const IndexQuery_js_1 = require("../../../Queries/IndexQuery.js");
class LazySuggestionQueryOperation {
// eslint-disable-next-line @typescript-eslint/ban-types
_result;
_queryResult;
_requiresRetry;
_session;
_indexQuery;
_invokeAfterQueryExecuted;
_processResults;
constructor(session, indexQuery, invokeAfterQueryExecuted, processResults) {
this._session = session;
this._indexQuery = indexQuery;
this._invokeAfterQueryExecuted = invokeAfterQueryExecuted;
this._processResults = processResults;
}
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;
}
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 QueryCommand_js_1.QueryCommand.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.LazySuggestionQueryOperation = LazySuggestionQueryOperation;
//# sourceMappingURL=LazySuggestionQueryOperation.js.map