Export a Postgres schema as JSON. Fork of https://github.com/tjwebb/pg-json-schema-export
$ npm install --save git+https://git@github.com/kiwicopple/pg-json-schema-export.git
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
})
The output format is for the most part named after the columns in information_schema
.
parameter | description |
---|---|
connection |
connection string or object compatible with pg |
schema |
the database schema to export |
MIT