ravendb
Version:
RavenDB client for Node.js
57 lines • 2.43 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractIndexCreationTaskBase = void 0;
const PutIndexesOperation_js_1 = require("../Operations/Indexes/PutIndexesOperation.js");
const AbstractCommonApiForIndexes_js_1 = require("./AbstractCommonApiForIndexes.js");
const DocumentStoreBase_js_1 = require("../DocumentStoreBase.js");
class AbstractIndexCreationTaskBase extends AbstractCommonApiForIndexes_js_1.AbstractCommonApiForIndexes {
conventions;
priority;
lockMode;
deploymentMode;
archivedDataProcessingBehavior;
searchEngineType;
state;
compoundFieldsStrings;
compoundField(firstField, secondField) {
this.compoundFieldsStrings ??= [];
this.compoundFieldsStrings.push([firstField, secondField]);
}
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_js_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.archivedDataProcessingBehavior) {
indexDefinition.archivedDataProcessingBehavior = this.archivedDataProcessingBehavior;
}
if (this.deploymentMode) {
indexDefinition.deploymentMode = this.deploymentMode;
}
await store.maintenance.forDatabase(database)
.send(new PutIndexesOperation_js_1.PutIndexesOperation(indexDefinition));
}
finally {
this.conventions = oldConventions;
}
}
}
exports.AbstractIndexCreationTaskBase = AbstractIndexCreationTaskBase;
//# sourceMappingURL=AbstractIndexCreationTaskBase.js.map