From 124f423acc55bfd8dcf93220562aa2f96f705df1 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei Date: Mon, 5 Aug 2024 12:44:03 +0400 Subject: [PATCH] feat: add delete db method --- package.json | 4 ++-- src/service/databaseManager.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7d7fd53..b5bf714 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@togethercrew.dev/db", - "version": "3.0.63", + "version": "3.0.64", "description": "All interactions with DB", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -55,4 +55,4 @@ "files": [ "dist/**/*" ] -} \ No newline at end of file +} diff --git a/src/service/databaseManager.ts b/src/service/databaseManager.ts index 49f355b..99415e8 100644 --- a/src/service/databaseManager.ts +++ b/src/service/databaseManager.ts @@ -65,4 +65,14 @@ export default class DatabaseManager { } } } + + // Method to delete a database using the connection + public async deleteDatabase(db: Connection): Promise { + const dbName = db.name; + try { + await db.dropDatabase(); + } catch (error) { + console.error(`Error deleting database ${dbName}:`, error); + } + } }