UNPKG

@configurator/ravendb

Version:
46 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractIndexCreationTaskBase = void 0; const PutIndexesOperation_1 = require("../Operations/Indexes/PutIndexesOperation"); const AbstractCommonApiForIndexes_1 = require("./AbstractCommonApiForIndexes"); const DocumentStoreBase_1 = require("../DocumentStoreBase"); const Constants_1 = require("../../Constants"); class AbstractIndexCreationTaskBase extends AbstractCommonApiForIndexes_1.AbstractCommonApiForIndexes { async execute(store, conventions, database) { if (!conventions && !database) { return store.executeIndex(this); } return this._putIndex(store, conventions, database); } async _putIndex(store, conventions, database) { const oldConventions = this.conventions; try { database = DocumentStoreBase_1.DocumentStoreBase.getEffectiveDatabase(store, database); this.conventions = conventions || this.conventions || store.getRequestExecutor(database).conventions; const indexDefinition = this.createIndexDefinition(); indexDefinition.name = this.getIndexName(); if (this.lockMode) { indexDefinition.lockMode = this.lockMode; } if (this.priority) { indexDefinition.priority = this.priority; } if (this.state) { indexDefinition.state = this.state; } if (this.deploymentMode) { indexDefinition.deploymentMode = this.deploymentMode; } if (this.searchEngineType) { indexDefinition.configuration[Constants_1.INDEXES.INDEXING_STATIC_SEARCH_ENGINE_TYPE] = this.searchEngineType; } await store.maintenance.forDatabase(database) .send(new PutIndexesOperation_1.PutIndexesOperation(indexDefinition)); } finally { this.conventions = oldConventions; } } } exports.AbstractIndexCreationTaskBase = AbstractIndexCreationTaskBase; //# sourceMappingURL=AbstractIndexCreationTaskBase.js.map