scripts: use db from connection string.
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 29 Jan 2021 22:04:52 +0000 (23:04 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 29 Jan 2021 22:04:52 +0000 (23:04 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/assets/configs-aws
src/scripts/deleteChargingStations.js
src/scripts/setCSPublicFlag.js

index 5c1897ea8127c73f6e063c2267214089719da194..03f3aba699def4fdfc3926674e469aef37e444d9 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5c1897ea8127c73f6e063c2267214089719da194
+Subproject commit 03f3aba699def4fdfc3926674e469aef37e444d9
index 2e84eeba9f9dc3b2cac283067b2eea7f3233788f..0dbefc07cd9c9286b68dd714e17a25d75b57ef1f 100755 (executable)
@@ -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(
index 3ecf5089460cdd5ddcf1b321685434100341d356..06502374c2be91d36e6696e6ab83dc6b18697d6d 100755 (executable)
@@ -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(