UNPKG

ravendb

Version:
70 lines 2.1 kB
import { StringUtil } from "../../../Utility/StringUtil.js"; import { throwError } from "../../../Exceptions/index.js"; import { DocumentCountersOperation } from "../../Operations/Counters/DocumentCountersOperation.js"; export class CountersBatchCommandData { _id; _name; _changeVector; _fromEtl; _counters; constructor(documentId, counterOperations) { if (StringUtil.isNullOrWhitespace(documentId)) { throwError("InvalidArgumentException", "DocumentId cannot be null."); } if (!counterOperations) { throwError("InvalidArgumentException", "Argument 'counterOperations' cannot be null."); } this._id = documentId; this._name = null; this._changeVector = null; this._counters = new 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 }; } } //# sourceMappingURL=CountersBatchCommandData.js.map