-
Notifications
You must be signed in to change notification settings - Fork 29
/
README.njk
33 lines (20 loc) · 995 Bytes
/
README.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{% include "module-header" %}
# 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.