@configurator/ravendb
Version:
RavenDB client for Node.js
31 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentInfo = void 0;
const Constants_1 = require("../../Constants");
const Exceptions_1 = require("../../Exceptions");
const TypeUtil_1 = require("../../Utility/TypeUtil");
class DocumentInfo {
static getNewDocumentInfo(document) {
const metadata = document[Constants_1.CONSTANTS.Documents.Metadata.KEY];
if (!metadata) {
(0, Exceptions_1.throwError)("InvalidOperationException", "Document must have a metadata");
}
const id = metadata[Constants_1.CONSTANTS.Documents.Metadata.ID];
if (TypeUtil_1.TypeUtil.isNullOrUndefined(id) || typeof id !== "string") {
(0, Exceptions_1.throwError)("InvalidOperationException", "Document must have an id");
}
const changeVector = metadata[Constants_1.CONSTANTS.Documents.Metadata.CHANGE_VECTOR];
if (TypeUtil_1.TypeUtil.isNullOrUndefined(changeVector) || typeof changeVector !== "string") {
(0, Exceptions_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