sequelize-es-decorator
Advanced tools
Comparing version 1.0.3 to 1.0.4
17
index.js
const elasticsearch = require('elasticsearch'); | ||
const { typeCheck } = require('type-check'); | ||
const { types } = require('./config/constants'); | ||
const {typeCheck} = require('type-check'); | ||
const {types} = require('./config/constants'); | ||
const decorateAdd = require('./methods/add'); | ||
@@ -10,3 +10,3 @@ const decorateUpdate = require('./methods/update'); | ||
class Decorator { | ||
constructor(esConfig, database) { | ||
constructor(esConfig, database, indexSetting) { | ||
if (esConfig) { | ||
@@ -23,2 +23,4 @@ this.client = new elasticsearch.Client(esConfig); | ||
} | ||
this.indexSetting = indexSetting; | ||
} | ||
@@ -35,5 +37,12 @@ | ||
if (!status) { | ||
this.client.indices.create({ | ||
this.client.indices.create(this.indexSetting ? { | ||
index: `${this.database}_${options.type}`, | ||
body: this.indexSetting | ||
} : { | ||
index: `${this.database}_${options.type}` | ||
}); | ||
} else if (this.indexSetting) { | ||
this.client.indices.close({index: `${this.database}_${options.type}`}) | ||
.then(() => this.client.indices.putSettings(this.indexSetting)) | ||
.then(() => this.client.indices.open({index: `${this.database}_${options.type}`})); | ||
} | ||
@@ -40,0 +49,0 @@ }); |
{ | ||
"name": "sequelize-es-decorator", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Decorator for Sequelize models that enables auto-indexing of data that goes through the model.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9291
163