ravendb
Version:
RavenDB client for Node.js
65 lines • 2.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoveCompareExchangeCommand = exports.DeleteCompareExchangeValueOperation = void 0;
const CompareExchangeResult_js_1 = require("./CompareExchangeResult.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const index_js_1 = require("../../../Exceptions/index.js");
const RaftIdGenerator_js_1 = require("../../../Utility/RaftIdGenerator.js");
class DeleteCompareExchangeValueOperation {
_key;
_index;
_clazz;
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_js_1.RavenCommand {
_key;
_index;
_clazz;
_conventions;
constructor(key, index, conventions, clazz) {
super();
if (!key) {
(0, index_js_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_js_1.CompareExchangeResult.parseFromObject(resObj, this._conventions, this._clazz);
return body;
}
getRaftUniqueRequestId() {
return RaftIdGenerator_js_1.RaftIdGenerator.newId();
}
}
exports.RemoveCompareExchangeCommand = RemoveCompareExchangeCommand;
//# sourceMappingURL=DeleteCompareExchangeValueOperation.js.map