Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ const GetSchema = require('get-schema')
✗ import GetSchema from 'get-schema'
CJS-only; no default export in ESM. Use require().
GetSchema
✓ const GetSchema = require('get-schema'); const schema = new GetSchema(client)
✗ const schema = new GetSchema.default(client)
Direct constructor call, no .default property.
schema.get
✓ schema.get('table_name', callback)
✗ schema.get('table_name').then(callback)
Callback-based, not Promise-based.
schema.getColumns
✓ schema.getColumns('table_name', callback)
✗ schema.getColumns('table_name') // no callback returns undefined
Callback required; does not return promise.
schema.getCreateTypes
✓ schema.getCreateTypes('table_name', callback)
✗ schema.getCreateTypes('table_name', callback) // forgot to pass client?
Requires valid pg client with query method.
Retrieves column names, data types, and CREATE types for a PostgreSQL table using a callback pattern.
const pg = require('pg');
const GetSchema = require('get-schema');
const conString = 'postgres://postgres:password@localhost/postgres';
pg.connect(conString, function(err, client, done) {
if (err) throw new Error(err);
const schema = new GetSchema(client);
schema.getColumns('registered_voters', function(err, columns) {
if (err) throw err;
console.log('Columns:', columns);
});
schema.get('registered_voters', function(err, types) {
if (err) throw err;
console.log('Types:', types);
});
schema.getCreateTypes('registered_voters', function(err, createTypes) {
if (err) throw err;
console.log('Create types:', createTypes);
done();
});
});
Errors
Common errors & fixes
TypeError: GetSchema is not a constructor
Importing the package incorrectly (e.g., using import syntax or wrong require path).
fixUse const GetSchema = require('get-schema'); and call new GetSchema(client). TypeError: schema.getColumns is not a function
schema not properly instantiated with a valid client.
fixEnsure GetSchema is called with a pg client: new GetSchema(client).
Cannot find module 'get-schema'
Package not installed.
fixRun 'npm install get-schema' in your project directory.
TypeError: callback is not a function
Calling schema.get, getColumns, or getCreateTypes without providing a callback.
fixPass a function as the second argument: schema.get('table', function(err, result) { ... }). Audit
Dependencies
pgrequiredRequired for PostgreSQL/Redshift client connection.