| 2 | // import * as ormConfig from '../../ormconfig'; |
| 3 | |
| 4 | export class Database { |
| 5 | public static instance: Database; |
| 6 | private conn: Connection | null; |
| 7 | |
| 8 | private constructor() { |
| 9 | this.conn = null; |
| 10 | } |
| 11 | |
| 12 | public static getInstance(): Database { |
| 13 | if (!Database.instance) { |
| 14 | Database.instance = new Database(); |
| 15 | } |
| 16 | return Database.instance; |
| 17 | } |
| 18 | |
| 19 | public async connectAndMigrate(logging: boolean) { |
| 20 | this.conn = await createConnection(); |
| 21 | await this.conn.runMigrations({ |
| 22 | transaction: 'all', |
| 23 | }); |
| 24 | } |
| 25 | |
| 26 | public async close() { |
| 27 | if (this.conn) { |
| 28 | await this.conn.close(); |
| 29 | this.conn = null; |
| 30 | } |
| 31 | } |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected