Export a Postgres database as JSON
$ npm install pg-json-data-export --save
var exporter = require('pg-json-data-export');
var connection = {
// pg connections object
};
exporter.toJSON(connection, 'public')
.then(function (dump) {
console.log(dump.table1.rows);
});
@param | description |
---|---|
connection |
connection string or object compatible with pg |
schema |
the database schema to export |
@return | description |
Object |
dump of all tables in database schema{ table1: { rows: [ { /* ... */ } ] } } |
MIT