Skip to content

kiwicopple/postgres-schema

 
 

Repository files navigation

postgres-schema

Export a Postgres schema as JSON. Fork of https://github.com/tjwebb/pg-json-schema-export

Install

$ npm install --save git+https://git@github.com/kiwicopple/pg-json-schema-export.git

Usage

var PostgresSchema = require('pg-json-schema-export')
var connection = {
  user: 'postgres',
  password: '123',
  host: 'localhost',
  port: 5432,
  database: 'thedb',
}
PostgresSchema.toJSON(connection, 'public')
  .then(({ tables, views, constraints, sequences, counts }) => {
    // handle json object
    console.log('tables', tables)
    console.log('views', views)
    console.log('constraints', constraints)
    console.log('sequences', sequences)
    console.log('counts', counts)
  })
  .catch(function(error) {
    // handle error
  })

Output Format

The output format is for the most part named after the columns in information_schema.

API

.toJSON(connection, schema)

parameter description
connection connection string or object compatible with pg
schema the database schema to export

License

MIT

About

Export Postgres schemas as JSON ( tables, constraints, sequences)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.2%
  • SQLPL 6.8%