ravendb
Version:
RavenDB client for Node.js
41 lines • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentInfo = void 0;
const Constants_js_1 = require("../../Constants.js");
const index_js_1 = require("../../Exceptions/index.js");
const TypeUtil_js_1 = require("../../Utility/TypeUtil.js");
class DocumentInfo {
id;
changeVector;
concurrencyCheckMode;
ignoreChanges;
metadata;
document;
metadataInstance;
entity;
newDocument;
collection;
static getNewDocumentInfo(document) {
const metadata = document[Constants_js_1.CONSTANTS.Documents.Metadata.KEY];
if (!metadata) {
(0, index_js_1.throwError)("InvalidOperationException", "Document must have a metadata");
}
const id = metadata[Constants_js_1.CONSTANTS.Documents.Metadata.ID];
if (TypeUtil_js_1.TypeUtil.isNullOrUndefined(id) || typeof id !== "string") {
(0, index_js_1.throwError)("InvalidOperationException", "Document must have an id");
}
const changeVector = metadata[Constants_js_1.CONSTANTS.Documents.Metadata.CHANGE_VECTOR];
if (TypeUtil_js_1.TypeUtil.isNullOrUndefined(changeVector) || typeof changeVector !== "string") {
(0, index_js_1.throwError)("InvalidOperationException", "Document must have an changeVector");
}
const newDocumentInfo = new DocumentInfo();
newDocumentInfo.id = id;
newDocumentInfo.document = document;
newDocumentInfo.metadata = metadata;
newDocumentInfo.entity = null;
newDocumentInfo.changeVector = changeVector;
return newDocumentInfo;
}
}
exports.DocumentInfo = DocumentInfo;
//# sourceMappingURL=DocumentInfo.js.map