UNPKG

ravendb

Version:
55 lines 2.69 kB
import { GetRevisionOperation } from "../GetRevisionOperation.js"; import { MetadataDictionary } from "../../../../Mapping/MetadataAsDictionary.js"; import { LazyRevisionOperation } from "./LazyRevisionOperation.js"; import { TypeUtil } from "../../../../Utility/TypeUtil.js"; export class LazyRevisionOperations { delegate; constructor(delegate) { this.delegate = delegate; } getMetadataFor(id, options) { options = Object.assign({ pageSize: 25, start: 0 }, options || {}); const operation = new GetRevisionOperation(this.delegate, id, options.start, options.pageSize); const lazyRevisionOperation = new LazyRevisionOperation(MetadataDictionary, operation, "ListOfMetadata"); return this.delegate.addLazyOperation(lazyRevisionOperation); } get(changeVectorOrVectorsOrId, documentTypeOrDate) { const documentType = TypeUtil.isDocumentType(documentTypeOrDate) ? documentTypeOrDate : undefined; if (TypeUtil.isDate(documentTypeOrDate)) { return this._getByIdAndDate(changeVectorOrVectorsOrId, documentTypeOrDate); } else { return this._get(changeVectorOrVectorsOrId, documentType); } } _get(changeVectorOrVectors, documentType) { if (TypeUtil.isArray(changeVectorOrVectors)) { const operation = new GetRevisionOperation(this.delegate, changeVectorOrVectors); const lazyRevisionOperation = new LazyRevisionOperation(documentType, operation, "Map"); return this.delegate.addLazyOperation(lazyRevisionOperation); } else { const operation = new GetRevisionOperation(this.delegate, changeVectorOrVectors); const lazyRevisionOperation = new LazyRevisionOperation(documentType, operation, "Single"); return this.delegate.addLazyOperation(lazyRevisionOperation); } } _getByIdAndDate(id, date, clazz) { const operation = new GetRevisionOperation(this.delegate, id, date); const lazyRevisionOperation = new LazyRevisionOperation(clazz, operation, "Single"); return this.delegate.addLazyOperation(lazyRevisionOperation); } getFor(id, options = {}) { const start = options.start ?? 0; const pageSize = options.pageSize ?? 25; const operation = new GetRevisionOperation(this.delegate, id, start, pageSize); const lazyRevisionOperation = new LazyRevisionOperation(options.documentType, operation, "Multi"); return this.delegate.addLazyOperation(lazyRevisionOperation); } } //# sourceMappingURL=LazyRevisionOperations.js.map