UNPKG

ravendb

Version:
74 lines 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CountersBatchCommandData = void 0; const StringUtil_js_1 = require("../../../Utility/StringUtil.js"); const index_js_1 = require("../../../Exceptions/index.js"); const DocumentCountersOperation_js_1 = require("../../Operations/Counters/DocumentCountersOperation.js"); class CountersBatchCommandData { _id; _name; _changeVector; _fromEtl; _counters; constructor(documentId, counterOperations) { if (StringUtil_js_1.StringUtil.isNullOrWhitespace(documentId)) { (0, index_js_1.throwError)("InvalidArgumentException", "DocumentId cannot be null."); } if (!counterOperations) { (0, index_js_1.throwError)("InvalidArgumentException", "Argument 'counterOperations' cannot be null."); } this._id = documentId; this._name = null; this._changeVector = null; this._counters = new DocumentCountersOperation_js_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