diff --git a/forward_engineering/api.js b/forward_engineering/api.js index bda8c4e..aedd0b8 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -247,9 +247,7 @@ module.exports = { relationship, child, bidirectional: - relationship && - relationship.customProperties && - relationship.customProperties.biDirectional && + relationship?.customProperties?.biDirectional && child.GUID !== parent.GUID, }); }); @@ -483,6 +481,8 @@ module.exports = { entities.relationships = relationships; } } + const getId = key => key.keyId; + Object.keys(entities).forEach(type => { entities[type].forEach(entity => { if (entity.index) { @@ -490,7 +490,7 @@ module.exports = { if (index.key) { const fields = this.findFields( entity, - index.key.map(key => key.keyId), + index.key.map(getId), ); if (fields.length) { const indexScript = getIndex({ @@ -674,23 +674,30 @@ const getTemporalFieldFunctionStatement = (fieldMode, fieldStatementValue) => { const timeSampleValue = JSON.stringify('12:00'); switch (fieldMode) { - case 'date': + case 'date': { return `date(${fieldStatementValue})`; - case 'datetime': + } + case 'datetime': { return `datetime(${fieldStatementValue})`; - case 'localdatetime': + } + case 'localdatetime': { return `localdatetime(${fieldStatementValue})`; - case 'localtime': + } + case 'localtime': { const localTimeStatementValue = isDefaultSample ? timeSampleValue : fieldStatementValue; return `localtime(${localTimeStatementValue})`; - case 'time': + } + case 'time': { const timeStatementValue = isDefaultSample ? timeSampleValue : fieldStatementValue; return `time(${timeStatementValue})`; - case 'duration': + } + case 'duration': { const durationStatementValue = isDefaultSample ? durationSampleValue : fieldStatementValue; return `duration(${durationStatementValue})`; - default: + } + default: { return fieldStatementValue; + } } }; diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 5b93dab..ee3b8fc 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -114,7 +114,7 @@ module.exports = { getDbCollectionsData: async function (data, logger, cb, app) { try { - this.getDbCollectionsDataWrapped(data, logger, cb, app); + await this.getDbCollectionsDataWrapped(data, logger, cb, app); } catch (error) { logger.log('error', prepareError(error), 'RE Get Collections Data'); cb(error); @@ -483,17 +483,17 @@ const getLabelPackage = ( const prepareIndexes3x = indexes => { const hasProperties = /INDEX\s+ON\s+\:(.*)\((.*)\)/i; - let map = {}; + const map = {}; indexes.forEach((index, i) => { - if (index.properties) { - index.properties = index.properties; - } else if (hasProperties.test(index.description)) { - let parsedDescription = index.description.match(hasProperties); - index.label = parsedDescription[1]; - index.properties = parsedDescription[2].split(',').map(s => s.trim()); - } else { - index.properties = []; + if (!index.properties) { + if (hasProperties.test(index.description)) { + const parsedDescription = index.description.match(hasProperties); + index.label = parsedDescription[1]; + index.properties = parsedDescription[2].split(',').map(s => s.trim()); + } else { + index.properties = []; + } } if (!map[index.label]) {