Warning
The relevant parts of this repo were rolled into https://github.com/feathers-studio/true-pg, which was the primary purpose of this project.
This project is no longer maintained.
Reads various metadata from your postgres database and return a Javascript object. This package was originally forked from extract-pg-schema by Kristian Dupont to extend its utility and to generate perfect types. It's now a standalone package.
Note: This package is a work in progress and may have missing features or broken modules. However, it's already being used to generate types by TruePG. You should probably use that instead.
Choose your package manager:
bun add pg-extract
npm i pg-extract
pnpm add pg-extract
You give it a postgres connection config object and some options and it will connect to your database and generate an object with the schema.
import { Extractor } from "pg-extract";
const extractor = new Extractor({
host: "localhost",
database: "postgres",
user: "postgres",
password: "postgres",
});
const result = await extractor.extractSchemas();
console.log(result);
We're grateful to Kristian Dupont and the other contributors to the extract-pg-schema project for the package we are building on top of.