ravendb
Version:
RavenDB client for Node.js
52 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExplainQueryCommand = void 0;
const RavenCommand_js_1 = require("../../Http/RavenCommand.js");
const IndexQuery_js_1 = require("../Queries/IndexQuery.js");
const index_js_1 = require("../../Exceptions/index.js");
class ExplainQueryCommand extends RavenCommand_js_1.RavenCommand {
_conventions;
_indexQuery;
constructor(conventions, indexQuery) {
super();
if (!conventions) {
(0, index_js_1.throwError)("InvalidArgumentException", "Conventions cannot be null");
}
if (!indexQuery) {
(0, index_js_1.throwError)("InvalidArgumentException", "IndexQuery cannot be null");
}
this._conventions = conventions;
this._indexQuery = indexQuery;
}
createRequest(node) {
const uri = node.url + "/databases/" + node.database + "/queries?debug=explain";
const headers = this._headers().typeAppJson().build();
return {
method: "POST",
uri,
body: (0, IndexQuery_js_1.writeIndexQuery)(this._conventions, this._indexQuery),
headers
};
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
this.result = null;
return;
}
let body = null;
const data = await this._defaultPipeline(_ => body = _)
.process(bodyStream);
const explainResults = data["results"];
if (!explainResults) {
this._throwInvalidResponse();
return;
}
this.result = explainResults;
return body;
}
get isReadRequest() {
return true;
}
}
exports.ExplainQueryCommand = ExplainQueryCommand;
//# sourceMappingURL=ExplainQueryCommand.js.map