MCPcopy Create free account
hub / github.com/RemoteState/nodejs-ecs / Database

Class Database

src/database/index.ts:4–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2// import * as ormConfig from '../../ormconfig';
3
4export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected