// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import { Configuration, Connection, IDatabaseDriver, MikroORM, Options } from '@mikro-orm/core';
+import {
+ Configuration,
+ Connection,
+ type IDatabaseDriver,
+ MikroORM,
+ type Options,
+} from '@mikro-orm/core';
import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
+import { Storage } from './Storage';
import {
- type MikroORMDBType,
+ type MikroOrmDbType,
PerformanceData,
PerformanceRecord,
type Statistics,
StorageType,
} from '../../types';
import { Constants } from '../../utils';
-import { Storage } from '../internal';
export class MikroOrmStorage extends Storage {
private storageType: StorageType;
- private orm!: MikroORM | null;
+ private orm?: MikroORM;
constructor(storageUri: string, logPrefix: string, storageType: StorageType) {
super(storageUri, logPrefix);
this.dbName = this.getDBName();
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public async storePerformanceStatistics(performanceStatistics: Statistics): Promise<void> {
try {
const performanceRecord = new PerformanceRecord();
try {
if (this?.orm) {
await this.orm.close();
- this.orm = null;
+ delete this?.orm;
}
} catch (error) {
this.handleDBError(this.storageType, error as Error);
return {
metadataProvider: TsMorphMetadataProvider,
entities: [PerformanceRecord, PerformanceData],
- type: this.storageType as MikroORMDBType,
+ type: this.storageType as MikroOrmDbType,
clientUrl: this.getClientUrl(),
};
}