File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Projects/BooksLibrary/src/database/sql/sequelize Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,16 @@ export class DatabaseConnector_Sequelize implements IDatabaseConnector {
8585 }
8686 } ;
8787
88- dropDatabase ( ) : Promise < boolean > {
89- throw new Error ( 'Method not implemented.' ) ;
90- }
88+ dropDatabase = async ( ) : Promise < boolean > => {
89+ try {
90+ const client = this . getClient ( ) ;
91+ await client . dropDb ( ) ;
92+ return true ;
93+ } catch ( error ) {
94+ Logger . instance ( ) . log ( error . message ) ;
95+ }
96+ return false ;
97+ } ;
9198
9299 executeQuery ( query : string ) : Promise < boolean > {
93100 throw new Error ( 'Method not implemented.' ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,16 @@ import { DbConfig } from '../database.config';
33import { Client } from 'pg' ;
44
55export class PostgresqlClient {
6+ static async dropDb ( ) {
7+ try {
8+ const config = DbConfig . config ;
9+ const query = `DROP DATABASE IF EXISTS ${ config . database } ` ;
10+ await PostgresqlClient . executeQuery ( query ) ;
11+ } catch ( error ) {
12+ Logger . instance ( ) . log ( error . message ) ;
13+ }
14+ }
15+
616 static async executeQuery ( query : string ) {
717 try {
818 const config = DbConfig . config ;
You can’t perform that action at this time.
0 commit comments