26 lines
902 B
TypeScript
26 lines
902 B
TypeScript
import * as plugins from './plugins.js';
|
|
import { Reception } from './classes.reception.js';
|
|
|
|
export class ReceptionDb {
|
|
public smartdataDb: plugins.smartdata.SmartdataDb;
|
|
public receptionRef: Reception;
|
|
|
|
constructor(receptionRefArg: Reception) {
|
|
this.receptionRef = receptionRefArg;
|
|
}
|
|
|
|
public async start(databaseNameArg?: string) {
|
|
this.smartdataDb = new plugins.smartdata.SmartdataDb({
|
|
mongoDbUser: await this.receptionRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_USER'),
|
|
mongoDbName: databaseNameArg || await this.receptionRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_NAME'),
|
|
mongoDbPass: await this.receptionRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_PASS'),
|
|
mongoDbUrl: await this.receptionRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_URL'),
|
|
});
|
|
await this.smartdataDb.init();
|
|
}
|
|
|
|
public async stop() {
|
|
await this.smartdataDb.close();
|
|
}
|
|
}
|