Merge branch 'master' into fix-template
[e-mobility-charging-stations-simulator.git] / src / scripts / deleteChargingStations.js
index 2e84eeba9f9dc3b2cac283067b2eea7f3233788f..3ebeb0942a1d007a18db7324cc12504088639816 100755 (executable)
@@ -6,19 +6,16 @@ const fs = require('fs');
 // This script deletes charging stations
 // Filter charging stations by id pattern
 
-// Use Case: ev-simulator creates thousands of charging stations, which are not longer needed.
+// Use Case: charging-stations-simulator creates thousands of charging stations, which are not longer needed.
 // Delete these charging stations all at once
 
 // Config
 const config = JSON.parse(fs.readFileSync('scriptConfig.json', 'utf8'));
 
 // Mongo Connection and Query
-if (config?.mongoConnectionString) {
-  MongoClient.connect(config.mongoConnectionString, {
-    useUnifiedTopology: true,
-    useNewUrlParser: true
-  }, async function(err, client) {
-    const db = client.db('evse');
+if (config && config.mongoConnectionString) {
+  MongoClient.connect(config.mongoConnectionString, async function(err, client) {
+    const db = client.db();
 
     for await (const tenantID of config.tenantIDs) {
       const response = await db.collection(tenantID + '.chargingstations').deleteMany(