diff --git a/package.json b/package.json index d2fce58..187f7cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@togethercrew.dev/db", - "version": "3.0.17", + "version": "3.0.18", "description": "All interactions with DB", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/service/databaseManager.ts b/src/service/databaseManager.ts index 2a22e4a..43f822e 100644 --- a/src/service/databaseManager.ts +++ b/src/service/databaseManager.ts @@ -28,14 +28,14 @@ export default class DatabaseManager { return DatabaseManager.instance; } - public getTenantDb(tenantId: Snowflake): Connection { + public async getTenantDb(tenantId: Snowflake): Promise { const dbName = tenantId; const db = mongoose.connection.useDb(dbName, { useCache: true }); - this.setupModels(db); + await this.setupModels(db); return db; } - private setupModels(db: Connection): void { + private async setupModels(db: Connection): Promise { if (!this.modelCache[db.name]) { db.model('HeatMap', heatMapSchema); db.model('RawInfo', rawInfoSchema);