ravendb
Version:
RavenDB client for Node.js
48 lines • 1.58 kB
JavaScript
import { RavenCommand } from "../../Http/RavenCommand.js";
import { writeIndexQuery } from "../Queries/IndexQuery.js";
import { throwError } from "../../Exceptions/index.js";
export class ExplainQueryCommand extends RavenCommand {
_conventions;
_indexQuery;
constructor(conventions, indexQuery) {
super();
if (!conventions) {
throwError("InvalidArgumentException", "Conventions cannot be null");
}
if (!indexQuery) {
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: 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;
}
}
//# sourceMappingURL=ExplainQueryCommand.js.map