ravendb
Version:
RavenDB client for Node.js
53 lines • 2.15 kB
JavaScript
import { PutIndexesOperation } from "../Operations/Indexes/PutIndexesOperation.js";
import { AbstractCommonApiForIndexes } from "./AbstractCommonApiForIndexes.js";
import { DocumentStoreBase } from "../DocumentStoreBase.js";
export class AbstractIndexCreationTaskBase extends 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.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(indexDefinition));
}
finally {
this.conventions = oldConventions;
}
}
}
//# sourceMappingURL=AbstractIndexCreationTaskBase.js.map