ravendb
Version:
RavenDB client for Node.js
37 lines • 1.43 kB
JavaScript
import { CONSTANTS } from "../../Constants.js";
import { throwError } from "../../Exceptions/index.js";
import { TypeUtil } from "../../Utility/TypeUtil.js";
export class DocumentInfo {
id;
changeVector;
concurrencyCheckMode;
ignoreChanges;
metadata;
document;
metadataInstance;
entity;
newDocument;
collection;
static getNewDocumentInfo(document) {
const metadata = document[CONSTANTS.Documents.Metadata.KEY];
if (!metadata) {
throwError("InvalidOperationException", "Document must have a metadata");
}
const id = metadata[CONSTANTS.Documents.Metadata.ID];
if (TypeUtil.isNullOrUndefined(id) || typeof id !== "string") {
throwError("InvalidOperationException", "Document must have an id");
}
const changeVector = metadata[CONSTANTS.Documents.Metadata.CHANGE_VECTOR];
if (TypeUtil.isNullOrUndefined(changeVector) || typeof changeVector !== "string") {
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;
}
}
//# sourceMappingURL=DocumentInfo.js.map