ravendb
Version:
RavenDB client for Node.js
51 lines • 1.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetIndexesStatisticsCommand = exports.GetIndexesStatisticsOperation = void 0;
const IndexStats_js_1 = require("../../Indexes/IndexStats.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
class GetIndexesStatisticsOperation {
get resultType() {
return "CommandResult";
}
getCommand(conventions) {
return new GetIndexesStatisticsCommand(conventions);
}
}
exports.GetIndexesStatisticsOperation = GetIndexesStatisticsOperation;
const typeInfo = {
nestedTypes: {
"results[].collections": "Map",
"results[].collections$MAP": "CollectionStats"
}
};
const knownTypes = new Map([[IndexStats_js_1.CollectionStats.name, IndexStats_js_1.CollectionStats]]);
class GetIndexesStatisticsCommand extends RavenCommand_js_1.RavenCommand {
_conventions;
constructor(conventions) {
super();
this._conventions = conventions;
}
createRequest(node) {
const uri = node.url + "/databases/" + node.database + "/indexes/stats";
return { uri };
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
this._throwInvalidResponse();
}
let body = null;
const results = await this._defaultPipeline(_ => body = _).process(bodyStream);
for (const r of results["results"]) {
r.collections = Object.keys(r.collections)
.reduce((result, next) => [...result, [next, result[next]]], []);
}
const obj = this._reviveResultTypes(results, this._conventions, typeInfo, knownTypes);
this.result = obj["results"];
return body;
}
get isReadRequest() {
return true;
}
}
exports.GetIndexesStatisticsCommand = GetIndexesStatisticsCommand;
//# sourceMappingURL=GetIndexesStatisticsOperation.js.map