UNPKG

@configurator/ravendb

Version:
69 lines 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CountersBatchCommandData = void 0; const StringUtil_1 = require("../../../Utility/StringUtil"); const Exceptions_1 = require("../../../Exceptions"); const DocumentCountersOperation_1 = require("../../Operations/Counters/DocumentCountersOperation"); class CountersBatchCommandData { constructor(documentId, counterOperations) { if (StringUtil_1.StringUtil.isNullOrWhitespace(documentId)) { (0, Exceptions_1.throwError)("InvalidArgumentException", "DocumentId cannot be null."); } if (!counterOperations) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Argument 'counterOperations' cannot be null."); } this._id = documentId; this._name = null; this._changeVector = null; this._counters = new DocumentCountersOperation_1.DocumentCountersOperation(); this._counters.documentId = documentId; this._counters.operations = Array.isArray(counterOperations) ? counterOperations : [counterOperations]; } get id() { return this._id; } get name() { return this._name; } get changeVector() { return this._changeVector; } get fromEtl() { return this._fromEtl; } get counters() { return this._counters; } get type() { return "Counters"; } hasDelete(counterName) { return this._hasOperationType("Delete", counterName); } hasIncrement(counterName) { return this._hasOperationType("Increment", counterName); } _hasOperationType(type, counterName) { for (const op of this._counters.operations) { if (counterName !== op.counterName) { continue; } if (op.type === type) { return true; } } return false; } serialize() { return { Id: this._id, Counters: this._counters.serialize(), Type: "Counters", FromEtl: this._fromEtl || undefined }; } } exports.CountersBatchCommandData = CountersBatchCommandData; //# sourceMappingURL=CountersBatchCommandData.js.map