Add an SQL DB abstraction layer

Because what self-respecting Enterprise(R) project doesn't have
one of those?
This commit is contained in:
Tau
2019-11-06 17:28:30 -05:00
parent 2ccd9dc382
commit 3e6b4f4798
32 changed files with 440 additions and 541 deletions
+19
View File
@@ -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>;
}