| 1 | import type { DatabaseEngineType } from "@struxa/db"; |
| 2 | import { mysqlAdapter } |
| 3 | import { postgresqlAdapter } |
| 4 | import { mongodbAdapter } |
| 5 | import { redisAdapter } |
| 6 | |
| 7 | export interface DbHostConn |
| 8 | host: string; |
| 9 | port: number; |
| 10 | username: string; |
| 11 | password: string; |
| 12 | ssl?: boolean |
| 13 | } |
| 14 | |
| 15 | export interface DbEngineAdapter |
| 16 | defaultPort: number; |
| 17 | testConnection(conn: |
| 18 | createDatabase( |
| 19 | conn: DbHostConn |
| 20 | opts: { |
| 21 | ): Promise<void |
| 22 | rotatePassword( |
| 23 | conn: DbHostConn |
| 24 | opts: { |
| 25 | ): Promise<void |
| 26 | dropDatabase( |
| 27 | conn: DbHostConn |
| 28 | opts: { |
| 29 | ): Promise<void |
| 30 | formatConnectionString(opts: |
| 31 | username: string |
| 32 | password: string |
| 33 | host: string |
| 34 | port: number |
| 35 | database: string |
| 36 | }): string; |
| 37 | } |
| 38 | |
| 39 | export const dbEngines: |
| 40 | mysql: mysqlAdapter, |
| 41 | mariadb: mysqlAdapter, |
| 42 | postgresql: postgresqlAdapter, |
| 43 | mongodb: mongodbAdapter, |
| 44 | redis: redisAdapter, |
| 45 | }; |