build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / src / performance / storage / MongoDBStorage.ts
index 48ce06d679d5131777542444bc46d87b3e40178b..c3c98022d4204c63aa6d940f7cac887d2424ed58 100644 (file)
@@ -2,10 +2,10 @@
 
 import { MongoClient } from 'mongodb'
 
-import { Storage } from './Storage.js'
 import { BaseError } from '../../exception/index.js'
 import { type Statistics, StorageType } from '../../types/index.js'
 import { Constants } from '../../utils/index.js'
+import { Storage } from './Storage.js'
 
 export class MongoDBStorage extends Storage {
   private readonly client?: MongoClient
@@ -20,6 +20,7 @@ export class MongoDBStorage extends Storage {
 
   public async storePerformanceStatistics (performanceStatistics: Statistics): Promise<void> {
     try {
+      this.setPerformanceStatistics(performanceStatistics)
       this.checkDBConnection()
       await this.client
         ?.db(this.dbName)
@@ -42,6 +43,7 @@ export class MongoDBStorage extends Storage {
   }
 
   public async close (): Promise<void> {
+    this.clearPerformanceStatistics()
     try {
       if (this.connected && this.client != null) {
         await this.client.close()