UNPKG

ravendb

Version:
62 lines 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetCompareExchangeValueCommand = exports.GetCompareExchangeValueOperation = void 0; const RavenCommand_js_1 = require("../../../Http/RavenCommand.js"); const index_js_1 = require("../../../Exceptions/index.js"); const CompareExchangeValueResultParser_js_1 = require("./CompareExchangeValueResultParser.js"); const GetCompareExchangeValuesOperation_js_1 = require("./GetCompareExchangeValuesOperation.js"); class GetCompareExchangeValueOperation { _key; _materializeMetadata; _clazz; constructor(key, clazz, materializeMetadata = true) { this._key = key; this._clazz = clazz; this._materializeMetadata = materializeMetadata; } getCommand(store, conventions, cache) { return new GetCompareExchangeValueCommand(this._key, this._materializeMetadata, conventions, this._clazz); } get resultType() { return "CommandResult"; } } exports.GetCompareExchangeValueOperation = GetCompareExchangeValueOperation; class GetCompareExchangeValueCommand extends RavenCommand_js_1.RavenCommand { _key; _clazz; _materializeMetadata; _conventions; constructor(key, materializeMetadata, conventions, clazz) { super(); if (!key) { (0, index_js_1.throwError)("InvalidArgumentException", "The key argument must have value"); } this._key = key; this._clazz = clazz; this._materializeMetadata = materializeMetadata; this._conventions = conventions; } get isReadRequest() { return true; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/cmpxchg?key=" + encodeURIComponent(this._key); return { uri }; } async setResponseAsync(bodyStream, fromCache) { if (!bodyStream) { return null; } let body = null; const results = await this._pipeline() .collectBody(x => body = x) .parseJsonSync() .process(bodyStream); const localObject = GetCompareExchangeValuesOperation_js_1.GetCompareExchangeValuesCommand.mapToLocalObject(results); this.result = CompareExchangeValueResultParser_js_1.CompareExchangeValueResultParser.getValue(localObject, this._materializeMetadata, this._conventions, this._clazz); return body; } } exports.GetCompareExchangeValueCommand = GetCompareExchangeValueCommand; //# sourceMappingURL=GetCompareExchangeValueOperation.js.map