一覧へ戻る
tjwebb/pg-json-schema-export(新しいタブで開きます)
主要言語: JavaScript
Export Postgres schemas as JSON ( tables, constraints, sequences)
- star 数
- 43
- watcher 数
- 2
- fork 数
- 16
- issue 数
- 3
- 最終更新
- 2022/05/11
主要言語: JavaScript
Export Postgres schemas as JSON ( tables, constraints, sequences)
Export a Postgres schema as JSON
$ npm install pg-json-schema-export --save
var PostgresSchema = require('pg-json-schema-export'); var connection = user: 'postgres', password: '123', host: 'localhost', port: 5432, database: 'thedb' }; PostgresSchema.toJSON(connection, 'public') .then(function (schemas) { // handle json object }) .catch(function (error) { // handle error });
The output format is for the most part named after the columns in information_schema.
{ "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
| parameter | description |
|---|---|
connection |
connection string or object compatible with pg |
schema |
the database schema to export |
MIT