From 26dbb742b78a6ddfc1bc20e81dc1cf2552b2d63b Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Tue, 26 Mar 2019 18:27:34 +0100 Subject: [PATCH] feat: expose a method to create your own generated index name newIndexName('an-index') -> 'an-index-1234-12-12t12:34:56.789z' --- README.md | 9 +++++++++ index.js | 2 ++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 15c7e7e..e50231c 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,15 @@ const {delete: del} = require('leaistic') await del('an-index') ``` +### Build a new Index name for a given alias (useful to manage some updates on your own) +```javascript +const { newIndexName } = require('leaistic') + +newIndexName('an-index') +// 'an-index-1234-12-12t12:34:56.789z' +``` + + ## ElasticSearch Connection By default, Leaistic will connect to `http://127.0.0.1:9200` or the value provided by `ES_URL` environment variable. diff --git a/index.js b/index.js index 0f1199b..2dd0335 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,8 @@ exports.create = (name, {indexTemplate} = {}) => lib.create(name, {body: indexTe exports.update = (name, {indexTemplate} = {}) => lib.update(name, {body: indexTemplate}) exports.delete = name => lib.delete(name) +exports.newIndexName = (aliasName) => lib.suffix(aliasName) + // override ES client or get a reference to it exports.connect = connect