Skip to content

Commit c43d6c9

Browse files
committed
Add TypeScriptTypes
1 parent 2e9b4cd commit c43d6c9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/lib/TypeScriptTypes.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { PostgresMeta } from "."
2+
3+
export default class TypeScriptTypes {
4+
pgMeta: PostgresMeta
5+
6+
constructor() {
7+
this.pgMeta = new PostgresMeta({
8+
connectionString: "postgres://postgres:postgres@localhost:5432/postgres",
9+
max: 1
10+
})
11+
}
12+
13+
async dump(): Promise<any> {
14+
const { data, error } = await this.pgMeta.columns.list();
15+
// TODO: handle error
16+
17+
if (data) {
18+
return data.reduce((prev, current) => {
19+
if (current.table in prev) {
20+
prev[current.table].push(current)
21+
} else {
22+
prev[current.table] = []
23+
}
24+
25+
return prev
26+
}, {} as { [key: string]: Array<any> })
27+
}
28+
}
29+
}
30+
31+
32+
new TypeScriptTypes().dump().then(console.log)

0 commit comments

Comments
 (0)