@configurator/ravendb
Version:
RavenDB client for Node.js
42 lines • 1.58 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatchCommandData = void 0;
const Exceptions_1 = require("../../../Exceptions");
const TypeUtil_1 = require("../../../Utility/TypeUtil");
class PatchCommandData {
constructor(id, changeVector, patch, patchIfMissing) {
this.name = null;
this.type = "PATCH";
if (!id) {
(0, Exceptions_1.throwError)("InvalidArgumentException", "Id cannot be null");
}
if (!patch) {
(0, Exceptions_1.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_1.TypeUtil.isNullOrUndefined(this.createIfMissing)) {
result["CreateIfMissing"] = this.createIfMissing;
}
if (!TypeUtil_1.TypeUtil.isNullOrUndefined(this.returnDocument)) {
result["ReturnDocument"] = this.returnDocument;
}
return result;
}
onBeforeSaveChanges(session) {
this.returnDocument = session.isLoaded(this.id);
}
}
exports.PatchCommandData = PatchCommandData;
//# sourceMappingURL=PatchCommandData.js.map