https://github.com/ozum/pg-structure
Get PostgreSQL database structure as a detailed JS Object.
https://github.com/ozum/pg-structure
Last synced: 6 days ago
JSON representation
Get PostgreSQL database structure as a detailed JS Object.
- Host: GitHub
- URL: https://github.com/ozum/pg-structure
- Owner: ozum
- License: mit
- Created: 2014-11-05T15:08:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T05:29:54.000Z (11 months ago)
- Last Synced: 2025-04-01T19:24:29.231Z (14 days ago)
- Language: TypeScript
- Homepage: http://www.pg-structure.com
- Size: 10.7 MB
- Stars: 358
- Watchers: 4
- Forks: 29
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ozum/pg-structure - Get PostgreSQL database structure as a detailed JS Object. (TypeScript)
README
# pg-structure
Reverse engineer PostgreSQL database as a detailed JS Object.
- [Home Page](#home-page)
- [Installation](#installation)
- [Synopsis](#synopsis)
- [Details](#details)# Home Page
Please see [pg-structure.com](https://www.pg-structure.com) for details.
# Installation
`$ npm install pg-structure`
# Synopsis
```ts
import pgStructure from "pg-structure";async function demo() {
// Prefer to use environment variables or ".env" file for the credentials. See the ".env.example" file.
const db = await pgStructure({ host: "host", database: "db", user: "u", password: "pass" }, { includeSchemas: ["public"] });const table = db.get("contact");
const columnNames = table.columns.map((c) => c.name);
const columnTypeName = table.columns.get("options").type.name;
const indexColumnNames = table.indexes.get("ix_mail").columns;
const relatedTables = table.hasManyTables;
}
```# Details
`pg-structure` reverse engineers PostgreSQL database and lets you easily code, analyze, operate on PostgreSQL database structure by providing details about DB, Schema, Table, Column, ForeignKey, Relation, Index, Type and others.