Skip to content

Commit

Permalink
add mysql connection
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Oct 8, 2024
1 parent 6ce6fdf commit 11f2dc0
Show file tree
Hide file tree
Showing 6 changed files with 372 additions and 9 deletions.
142 changes: 140 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.4",
"mysql2": "^3.11.3",
"prettier": "^3.2.5",
"ts-jest": "^29.1.3",
"ts-node": "^10.9.2",
Expand Down
10 changes: 8 additions & 2 deletions src/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export type OperationResponse = {
error: Error | null
}

export interface QueryResult<T = Record<string, unknown>> {
data: T[]
error: Error | null
query: string
}

export interface Connection {
queryType: QueryType
dialect: AbstractDialect
Expand All @@ -18,9 +24,9 @@ export interface Connection {
disconnect: () => Promise<any>

// Raw query execution method that can be used to execute any query.
query: (
query: <T = Record<string, unknown>>(
query: Query
) => Promise<{ data: any; error: Error | null; query: string }>
) => Promise<QueryResult<T>>

// Retrieve metadata about the database, useful for introspection.
fetchDatabaseSchema?: () => Promise<Database>
Expand Down
Loading

0 comments on commit 11f2dc0

Please sign in to comment.