ravendb
Version:
RavenDB client for Node.js
77 lines • 2.52 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LazyRevisionOperation = void 0;
const GetRequest_js_1 = require("../../../Commands/MultiGet/GetRequest.js");
const index_js_1 = require("../../../../Exceptions/index.js");
class LazyRevisionOperation {
_clazz;
_getRevisionOperation;
_mode;
_result;
_queryResult;
_requiresRetry;
constructor(clazz, getRevisionOperation, mode) {
this._clazz = clazz;
this._getRevisionOperation = getRevisionOperation;
this._mode = mode;
}
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;
}
createRequest() {
const getRevisionsCommand = this._getRevisionOperation.command;
const getRequest = new GetRequest_js_1.GetRequest();
getRequest.method = "GET";
getRequest.url = "/revisions";
getRequest.query = "?" + getRevisionsCommand.getRequestQueryString();
return getRequest;
}
async handleResponseAsync(response) {
if (!response.result) {
return;
}
const responseAsNode = JSON.parse(response.result);
const jsonArrayResult = {
results: responseAsNode.Results
};
this._getRevisionOperation.result = jsonArrayResult;
switch (this._mode) {
case "Single": {
this._result = this._getRevisionOperation.getRevision(this._clazz);
break;
}
case "Multi": {
this._result = this._getRevisionOperation.getRevisionsFor(this._clazz);
break;
}
case "Map": {
this._result = this._getRevisionOperation.getRevisions(this._clazz);
break;
}
case "ListOfMetadata": {
this._result = this._getRevisionOperation.getRevisionsMetadataFor();
break;
}
default: {
(0, index_js_1.throwError)("InvalidArgumentException", "Invalid mode: " + this._mode);
}
}
}
}
exports.LazyRevisionOperation = LazyRevisionOperation;
//# sourceMappingURL=LazyRevisionOperation.js.map