Add an SQL DB abstraction layer
Because what self-respecting Enterprise(R) project doesn't have one of those?
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import * as sql from "sql-bricks-postgres";
|
||||
|
||||
export type Id<T> = bigint & { __id: T };
|
||||
|
||||
export interface Row {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
modify(stmt: sql.Statement): Promise<void>;
|
||||
|
||||
fetchRow(stmt: sql.SelectStatement): Promise<Row | undefined>;
|
||||
|
||||
fetchRows(stmt: sql.SelectStatement): Promise<Row[]>;
|
||||
}
|
||||
|
||||
export interface DataSource {
|
||||
transaction<T>(callback: (txn: Transaction) => Promise<T>): Promise<T>;
|
||||
}
|
||||
Reference in New Issue
Block a user