31 lines
1010 B
TypeScript
31 lines
1010 B
TypeScript
|
---
|
||
|
fileName: {{module.name}}.classes.{{module.name}}db.ts
|
||
|
---
|
||
|
import * as plugins from './{{module.name}}.plugins.js';
|
||
|
import { {{module.name}} } from './{{module.name}}.classes.{{module.name}}.js';
|
||
|
|
||
|
|
||
|
|
||
|
export class {{module.name}}Db {
|
||
|
public smartdataDb: plugins.smartdata.SmartdataDb;
|
||
|
public {{module.name}}Ref: {{module.name}};
|
||
|
|
||
|
constructor({{module.name}}RefArg: {{module.name}}) {
|
||
|
this.{{module.name}}Ref = {{module.name}}RefArg;
|
||
|
}
|
||
|
|
||
|
public async start() {
|
||
|
this.smartdataDb = new plugins.smartdata.SmartdataDb({
|
||
|
mongoDbUser: this.{{module.name}}Ref.serviceQenv.getEnvVarOnDemand('MONGO_DB_USER'),
|
||
|
mongoDbName: this.{{module.name}}Ref.serviceQenv.getEnvVarOnDemand('MONGO_DB_NAME'),
|
||
|
mongoDbPass: this.{{module.name}}Ref.serviceQenv.getEnvVarOnDemand('MONGO_DB_PASS'),
|
||
|
mongoDbUrl: this.{{module.name}}Ref.serviceQenv.getEnvVarOnDemand('MONGO_DB_URL'),
|
||
|
});
|
||
|
await this.smartdataDb.init();
|
||
|
}
|
||
|
|
||
|
public async stop() {
|
||
|
await this.smartdataDb.close();
|
||
|
}
|
||
|
}
|