platformservice/ts/classes.platformservicedb.ts
2024-02-16 13:28:40 +01:00

28 lines
945 B
TypeScript

import * as plugins from './plugins.js';
import { SzPlatformService } from './classes.platformservice.js';
export class PlatformServiceDb {
public smartdataDb: plugins.smartdata.SmartdataDb;
public platformserviceRef: SzPlatformService;
constructor(platformserviceRefArg: SzPlatformService) {
this.platformserviceRef = platformserviceRefArg;
}
public async start() {
this.smartdataDb = new plugins.smartdata.SmartdataDb({
mongoDbUser: await this.platformserviceRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_USER'),
mongoDbName: await this.platformserviceRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_NAME'),
mongoDbPass: await this.platformserviceRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_PASS'),
mongoDbUrl: await this.platformserviceRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_URL'),
});
await this.smartdataDb.init();
}
public async stop() {
await this.smartdataDb.close();
}
}