UNPKG

ravendb

Version:
44 lines 1.46 kB
import { throwError } from "../../../Exceptions/index.js"; import { TypeUtil } from "../../../Utility/TypeUtil.js"; export class PatchCommandData { id; name = null; createIfMissing; changeVector; patch; patchIfMissing; type = "PATCH"; returnDocument; constructor(id, changeVector, patch, patchIfMissing) { if (!id) { throwError("InvalidArgumentException", "Id cannot be null"); } if (!patch) { throwError("InvalidArgumentException", "Patch cannot be null"); } this.id = id; this.patch = patch; this.changeVector = changeVector; this.patchIfMissing = patchIfMissing; } serialize(conventions) { const result = { Id: this.id, ChangeVector: this.changeVector, Type: "PATCH", Patch: this.patch.serialize(conventions), PatchIfMissing: this.patchIfMissing ? this.patchIfMissing.serialize(conventions) : undefined }; if (!TypeUtil.isNullOrUndefined(this.createIfMissing)) { result["CreateIfMissing"] = this.createIfMissing; } if (!TypeUtil.isNullOrUndefined(this.returnDocument)) { result["ReturnDocument"] = this.returnDocument; } return result; } onBeforeSaveChanges(session) { this.returnDocument = session.isLoaded(this.id); } } //# sourceMappingURL=PatchCommandData.js.map