From c43d6c91ec99de0c52a743570e6033a8177c5923 Mon Sep 17 00:00:00 2001 From: Nicholas Koh Date: Thu, 13 May 2021 00:06:11 +0800 Subject: [PATCH] Add TypeScriptTypes --- src/lib/TypeScriptTypes.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/lib/TypeScriptTypes.ts diff --git a/src/lib/TypeScriptTypes.ts b/src/lib/TypeScriptTypes.ts new file mode 100644 index 000000000..882e2063e --- /dev/null +++ b/src/lib/TypeScriptTypes.ts @@ -0,0 +1,32 @@ +import { PostgresMeta } from "." + +export default class TypeScriptTypes { + pgMeta: PostgresMeta + + constructor() { + this.pgMeta = new PostgresMeta({ + connectionString: "postgres://postgres:postgres@localhost:5432/postgres", + max: 1 + }) + } + + async dump(): Promise { + const { data, error } = await this.pgMeta.columns.list(); + // TODO: handle error + + if (data) { + return data.reduce((prev, current) => { + if (current.table in prev) { + prev[current.table].push(current) + } else { + prev[current.table] = [] + } + + return prev + }, {} as { [key: string]: Array }) + } + } +} + + +new TypeScriptTypes().dump().then(console.log)