pg-json-schema-export
Export a Postgres schema as JSON
Install
$ npm install pg-json-schema-export --save
Usage
var PostgresSchema = ;var connection = user: 'postgres' password: '123' host: 'localhost' port: 5432 database: 'thedb'};PostgresSchema ;
Output Format
The output format is for the most part named after the columns in information_schema
.
Structure
- schemas
- views
- columns
- tables
- columns
- sequences
- views
JSON
"tables": "user": "obj_description": "This table has Users in it" "columns": "name": "data_type": "text" // ... more columns // ... more tables "constraints": // column constraints, grouped by table "sequences": // column sequences, grouped by table
I auto-generate some JSON during each CI build; those are uploaded as Github releases: https://github.com/tjwebb/pg-json-schema-export/releases/latest
API
.toJSON(connection, schema)
parameter | description |
---|---|
connection |
connection string or object compatible with pg |
schema |
the database schema to export |
License
MIT