fixed up di
This commit is contained in:
parent
d63025de90
commit
8550b1de57
5 changed files with 19 additions and 56 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { Collection, Db, MongoClient, OptionalUnlessRequiredId } from 'mongodb';
|
||||
import type { Logger } from '@stock-bot/core/logger';
|
||||
import type { DocumentBase, MongoDBClientConfig, PoolMetrics, ConnectionEvents, DynamicPoolConfig } from './types';
|
||||
|
||||
/**
|
||||
|
|
@ -12,17 +13,17 @@ export class MongoDBClient {
|
|||
private db: Db | null = null;
|
||||
private readonly config: MongoDBClientConfig;
|
||||
private defaultDatabase: string;
|
||||
private readonly logger: any;
|
||||
private readonly logger: Logger;
|
||||
private isConnected = false;
|
||||
private readonly metrics: PoolMetrics;
|
||||
private readonly events?: ConnectionEvents;
|
||||
private dynamicPoolConfig?: DynamicPoolConfig;
|
||||
private poolMonitorInterval?: Timer;
|
||||
|
||||
constructor(config: MongoDBClientConfig, logger?: any, events?: ConnectionEvents) {
|
||||
this.config = config;
|
||||
this.defaultDatabase = config.database || 'stock';
|
||||
this.logger = logger || console;
|
||||
constructor(mongoConfig: MongoDBClientConfig, logger: Logger, events?: ConnectionEvents) {
|
||||
this.config = mongoConfig;
|
||||
this.defaultDatabase = mongoConfig.database || 'stock';
|
||||
this.logger = logger;
|
||||
this.events = events;
|
||||
this.metrics = {
|
||||
totalConnections: 0,
|
||||
|
|
@ -311,7 +312,7 @@ export class MongoDBClient {
|
|||
* Get a collection (interface compatibility method)
|
||||
* This method provides compatibility with the IMongoDBClient interface
|
||||
*/
|
||||
collection(name: string, database?: string): Collection<any> {
|
||||
collection(name: string, database?: string): Collection<DocumentBase> {
|
||||
return this.getCollection(name, database);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue