From: Jérôme Benoit Date: Fri, 29 Jan 2021 22:04:52 +0000 (+0100) Subject: scripts: use db from connection string. X-Git-Tag: v1.0.1-0~105^2~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=eaa20d18f0351dc64364f43ce477af45b46acc89;p=e-mobility-charging-stations-simulator.git scripts: use db from connection string. Signed-off-by: Jérôme Benoit --- diff --git a/src/assets/configs-aws b/src/assets/configs-aws index 5c1897ea..03f3aba6 160000 --- a/src/assets/configs-aws +++ b/src/assets/configs-aws @@ -1 +1 @@ -Subproject commit 5c1897ea8127c73f6e063c2267214089719da194 +Subproject commit 03f3aba699def4fdfc3926674e469aef37e444d9 diff --git a/src/scripts/deleteChargingStations.js b/src/scripts/deleteChargingStations.js index 2e84eeba..0dbefc07 100755 --- a/src/scripts/deleteChargingStations.js +++ b/src/scripts/deleteChargingStations.js @@ -13,12 +13,12 @@ const fs = require('fs'); const config = JSON.parse(fs.readFileSync('scriptConfig.json', 'utf8')); // Mongo Connection and Query -if (config?.mongoConnectionString) { +if (config && config.mongoConnectionString) { MongoClient.connect(config.mongoConnectionString, { useUnifiedTopology: true, useNewUrlParser: true }, async function(err, client) { - const db = client.db('evse'); + const db = client.db(); for await (const tenantID of config.tenantIDs) { const response = await db.collection(tenantID + '.chargingstations').deleteMany( diff --git a/src/scripts/setCSPublicFlag.js b/src/scripts/setCSPublicFlag.js index 3ecf5089..06502374 100755 --- a/src/scripts/setCSPublicFlag.js +++ b/src/scripts/setCSPublicFlag.js @@ -14,12 +14,12 @@ const fs = require('fs'); const config = JSON.parse(fs.readFileSync('scriptConfig.json', 'utf8')); // Mongo Connection and Query -if (config?.mongoConnectionString) { +if (config && config.mongoConnectionString) { MongoClient.connect(config.mongoConnectionString, { useUnifiedTopology: true, useNewUrlParser: true }, async function(err, client) { - const db = client.db('evse'); + const db = client.db(); for await (const tenantID of config.tenantIDs) { const response = await db.collection(tenantID + '.chargingstations').updateMany(