From ed2eec66fcbe6c86c5bdd5d61781d00dd593a475 Mon Sep 17 00:00:00 2001 From: Pascal Desmarets Date: Tue, 4 Dec 2018 20:53:02 +0100 Subject: [PATCH] Forward-engineering of CURL script --- forward_engineering/api.js | 3 ++- package.json | 4 ++-- reverse_engineering/api.js | 10 +++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 602cb9f..9043dc0 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -3,7 +3,8 @@ const schemaHelper = require('../helper/schemaHelper.js'); module.exports = { generateScript(data, logger, cb) { - const { jsonSchema, modelData, containerData, entityData, isUpdateScript } = data; + const { jsonSchema, modelData, entityData, isUpdateScript } = data; + const containerData = data.containerData || {}; let result = ""; let fieldsSchema = this.getFieldsSchema({ jsonSchema: JSON.parse(jsonSchema), diff --git a/package.json b/package.json index f515d0e..864e6cc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Elasticsearch", - "version": "0.1.12", - "versionDate": "2018-10-26", + "version": "0.1.13", + "versionDate": "2018-12-04", "author": "hackolade", "engines": { "hackolade": "1.12.7", diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 4e05825..32e2072 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -186,7 +186,7 @@ module.exports = { logger.log('info', { modelInfo }, 'Model info'); getMapping(null, client, modelInfo) - }).catch(() => getMapping(null, client)); + }, () => getMapping(null, client)); }, (client, modelInfo, getData) => { @@ -195,12 +195,16 @@ module.exports = { }, (err) => { logger.log('error', err, 'Error of getting schema'); getData(null, client, modelInfo, null); + }).catch(err => { + logger.log('error', err); + this.disconnect(data, logger, () => {}); + cb(err); }); }, (client, modelInfo, jsonSchemas, next) => { async.map(indices, (indexName, nextIndex) => { - let bucketInfo = Object.assign(getBucketData(jsonSchemas[indexName]), defaultBucketInfo); + let bucketInfo = Object.assign(getBucketData(jsonSchemas[indexName] || {}), defaultBucketInfo); if (!types[indexName]) { if (includeEmptyCollection) { nextIndex(null, [{ @@ -315,7 +319,7 @@ module.exports = { ], (err, items, modelInfo) => { if (err) { logger.log('error', err); - this.disconnect(connectionInfo, logger, () => {}); + this.disconnect(data, logger, () => {}); } cb(err, items, modelInfo);