ravendb
Version:
RavenDB client for Node.js
56 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IndexHasChangedCommand = exports.IndexHasChangedOperation = void 0;
const index_js_1 = require("../../../Exceptions/index.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const HttpUtil_js_1 = require("../../../Utility/HttpUtil.js");
class IndexHasChangedOperation {
_definition;
constructor(definition) {
if (!definition) {
(0, index_js_1.throwError)("InvalidArgumentException", "IndexDefinition cannot be null");
}
this._definition = definition;
}
getCommand(conventions) {
return new IndexHasChangedCommand(conventions, this._definition);
}
get resultType() {
return "CommandResult";
}
}
exports.IndexHasChangedOperation = IndexHasChangedOperation;
class IndexHasChangedCommand extends RavenCommand_js_1.RavenCommand {
_definition;
constructor(conventions, definition) {
super();
this._definition = conventions.objectMapper.toObjectLiteral(definition);
}
get isReadRequest() {
return false;
}
createRequest(node) {
const uri = node.url + "/databases/" + node.database + "/indexes/has-changed";
const body = this._serializer.serialize(this._definition);
const headers = HttpUtil_js_1.HeadersBuilder.create()
.typeAppJson().build();
return {
method: "POST",
uri,
body,
headers
};
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
this._throwInvalidResponse();
}
let body = null;
const results = await this._defaultPipeline(_ => body = _)
.process(bodyStream);
this.result = results["changed"];
return body;
}
}
exports.IndexHasChangedCommand = IndexHasChangedCommand;
//# sourceMappingURL=IndexHasChangedOperation.js.map