@configurator/ravendb
Version:
RavenDB client for Node.js
58 lines • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoveCompareExchangeCommand = exports.DeleteCompareExchangeValueOperation = void 0;
const CompareExchangeResult_1 = require("./CompareExchangeResult");
const RavenCommand_1 = require("../../../Http/RavenCommand");
const Exceptions_1 = require("../../../Exceptions");
const RaftIdGenerator_1 = require("../../../Utility/RaftIdGenerator");
class DeleteCompareExchangeValueOperation {
constructor(key, index, clazz) {
this._key = key;
this._index = index;
this._clazz = clazz;
}
getCommand(store, conventions, cache) {
return new RemoveCompareExchangeCommand(this._key, this._index, conventions, this._clazz);
}
get resultType() {
return "CommandResult";
}
}
exports.DeleteCompareExchangeValueOperation = DeleteCompareExchangeValueOperation;
class RemoveCompareExchangeCommand extends RavenCommand_1.RavenCommand {
constructor(key, index, conventions, clazz) {
super();
if (!key) {
(0, Exceptions_1.throwError)("InvalidArgumentException", "The key argument must have value.");
}
this._clazz = clazz;
this._key = key;
this._index = index;
this._conventions = conventions;
}
get isReadRequest() {
return true;
}
createRequest(node) {
const uri = node.url + "/databases/" + node.database + "/cmpxchg?key=" + encodeURIComponent(this._key)
+ "&index=" + this._index;
return {
method: "DELETE",
uri
};
}
async setResponseAsync(bodyStream, fromCache) {
let body = null;
const resObj = await this._pipeline()
.collectBody(_ => body = _)
.parseJsonSync()
.process(bodyStream);
this.result = CompareExchangeResult_1.CompareExchangeResult.parseFromObject(resObj, this._conventions, this._clazz);
return body;
}
getRaftUniqueRequestId() {
return RaftIdGenerator_1.RaftIdGenerator.newId();
}
}
exports.RemoveCompareExchangeCommand = RemoveCompareExchangeCommand;
//# sourceMappingURL=DeleteCompareExchangeValueOperation.js.map