From c10452b83c572096828df5a9cf0615ca4481cd7e Mon Sep 17 00:00:00 2001 From: Pascal Desmarets Date: Fri, 15 Jan 2021 18:38:56 +0100 Subject: [PATCH 1/2] fe menu title --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e59ef8f..0b266e9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "CosmosDB-with-SQL-API", - "version": "0.1.21", - "versionDate": "2021-01-08", + "version": "0.1.22", + "versionDate": "2021-01-15", "author": "hackolade", "engines": { "hackolade": "4.3.1", From 260cd693c1ee21b0657a9d3276a16987590534d5 Mon Sep 17 00:00:00 2001 From: Lench Volodymyr Date: Tue, 19 Jan 2021 11:38:53 +0200 Subject: [PATCH 2/2] add partition key to cosmosdb script and remove entity name from partition key --- forward_engineering/api.js | 6 ++++++ forward_engineering/applyToInstance/index.js | 12 +----------- .../container_level/containerLevelConfig.json | 3 +++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 2a0bbe3..a465dbb 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -6,6 +6,7 @@ module.exports = { try { const _ = app.require('lodash'); const script = { + partitionKey: getPartitionKey(_)(data.containerData), indexingPolicy: getIndexPolicyScript(_)(data.containerData), sample: data.entities.map(entityId => updateSample( JSON.parse(data.jsonData[entityId]), @@ -25,6 +26,7 @@ module.exports = { try { const _ = app.require('lodash'); const script = { + partitionKey: getPartitionKey(_)(data.containerData), indexingPolicy: getIndexPolicyScript(_)(data.containerData), sample: updateSample( JSON.parse(data.jsonData), @@ -58,6 +60,10 @@ const updateSample = (sample, containerData, entityData) => { }; }; +const getPartitionKey = (_) => (containerData) => { + return _.get(containerData, '[0].partitionKey[0].name'); +}; + const add = (key, items, mapper) => (script) => { if (!items.length) { return script; diff --git a/forward_engineering/applyToInstance/index.js b/forward_engineering/applyToInstance/index.js index 78fec6f..b5dc447 100644 --- a/forward_engineering/applyToInstance/index.js +++ b/forward_engineering/applyToInstance/index.js @@ -63,16 +63,6 @@ const updateIndexingPolicy = (indexes) => { return result; }; -const getPartitionKey = (_) => (containerData) => { - const partitionKey = _.get(containerData, '[0].partitionKey[0].name'); - - if (!partitionKey) { - return; - } - - return '/' + partitionKey.split('.').slice(1).join('/'); -}; - const getUniqueKeys = (uniqueKeys) => { if (!uniqueKeys) { return []; @@ -116,7 +106,7 @@ module.exports = { const { container, resource: containerDef } = await database.containers.createIfNotExists({ id: containerId, - partitionKey: getPartitionKey(_)(containerData), + partitionKey: script.partitionKey, defaultTtl: helper.getTTL(containerData), }); diff --git a/properties_pane/container_level/containerLevelConfig.json b/properties_pane/container_level/containerLevelConfig.json index 9dcb991..a6be8df 100644 --- a/properties_pane/container_level/containerLevelConfig.json +++ b/properties_pane/container_level/containerLevelConfig.json @@ -163,6 +163,9 @@ making sure that you maintain a proper JSON format. "propertyType": "fieldList", "template": "orderedList", "templateOptions": { + "divider": "/", + "front": true, + "entityName": false, "maxField": 1 } },