UNPKG

ravendb

Version:
96 lines 3.79 kB
import { IndexDefinition } from "./IndexDefinition.js"; import { AbstractIndexCreationTaskBase } from "./AbstractIndexCreationTaskBase.js"; import { INDEXES } from "../../Constants.js"; /** * Utility class to create javascript based indexes using not-strongly typed syntax. * * Use AbstractJavaScriptIndexCreationTask for strongly-typed javascript indexes. */ export class AbstractRawJavaScriptIndexCreationTask extends AbstractIndexCreationTaskBase { _definition = new IndexDefinition(); constructor() { super(); } get maps() { return this._definition.maps; } set maps(value) { this._definition.maps = value; } get fields() { return this._definition.fields; } set fields(value) { this._definition.fields = value; } get reduce() { return this._definition.reduce; } set reduce(value) { this._definition.reduce = value; } get isMapReduce() { return !!this.reduce; } /** * @return If not null than each reduce result will be created as a document in the specified collection name. */ get outputReduceToCollection() { return this._definition.outputReduceToCollection; } /** * @param value If not null than each reduce result will be created as a document in the specified collection name. */ set outputReduceToCollection(value) { this._definition.outputReduceToCollection = value; } /** * @return Defines a collection name for reference documents created based on provided pattern */ get patternReferencesCollectionName() { return this._definition.patternReferencesCollectionName; } /** * @param value Defines a collection name for reference documents created based on provided pattern */ set patternReferencesCollectionName(value) { this._definition.patternReferencesCollectionName = value; } /** * @return Defines a collection name for reference documents created based on provided pattern */ get patternForOutputReduceToCollectionReferences() { return this._definition.patternForOutputReduceToCollectionReferences; } /** * @param value Defines a collection name for reference documents created based on provided pattern */ set patternForOutputReduceToCollectionReferences(value) { this._definition.patternForOutputReduceToCollectionReferences = value; } createIndexDefinition() { this._definition.name = this.getIndexName(); this._definition.type = this.isMapReduce ? "JavaScriptMapReduce" : "JavaScriptMap"; this._definition.name = this.getIndexName(); if (this.additionalSources) { this._definition.additionalSources = this.additionalSources; } else { this._definition.additionalSources = {}; } this._definition.additionalAssemblies = this.additionalAssemblies || []; this._definition.configuration = this.configuration; this._definition.lockMode = this.lockMode; this._definition.priority = this.priority; this._definition.state = this.state; this._definition.deploymentMode = this.deploymentMode; if (this.searchEngineType && this.searchEngineType !== "None") { this._definition.configuration[INDEXES.INDEXING_STATIC_SEARCH_ENGINE_TYPE] = this.searchEngineType; } else if (this._definition.fields && Object.values(this._definition.fields).some(fieldOptions => fieldOptions.vector)) { this._definition.configuration[INDEXES.INDEXING_STATIC_SEARCH_ENGINE_TYPE] = "Corax"; } return this._definition; } } //# sourceMappingURL=AbstractRawJavaScriptIndexCreationTask.js.map