Registry / database / get-schema

get-schema

JSON →
library0.1.11jsnpmunverified

A simple utility to retrieve Redshift / PostgreSQL table schemas, version 0.1.11. Released sparingly (last update years ago). Returns column names, types, and CREATE types (including character lengths). Relies on a pg client instance from the 'pg' package. No TypeScript definitions or ESM support.

npm install get-schema
INSTALL
IMPORT
SIG · GET-SCHEMA
G
get-schema
databasejavascriptv0.1.11
harness data pending
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(); }); });
Debug
Known issues
gotchaCallback-based API; no promise support. Using .then() will cause runtime error.
fix
Use callbacks or promisify manually with util.promisify().
affects: >=0.0.0
gotchaRequires a pg client instance with a .query() method. Fails silently if client is not connected or invalid.
fix
Ensure pg client is properly connected before creating GetSchema instance.
affects: >=0.0.0
deprecatedPackage is no longer maintained; last release 0.1.11 may have unpatched issues.
fix
Consider forking or using alternative like 'pg-schema'.
affects: 0.1.11
gotchagetCreateTypes includes character length for varchar columns; get does not. Inconsistent output may cause confusion.
fix
Use getCreateTypes when exact column definitions are needed.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: GetSchema is not a constructor
Importing the package incorrectly (e.g., using import syntax or wrong require path).
fix
Use 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.
fix
Ensure GetSchema is called with a pg client: new GetSchema(client).
Cannot find module 'get-schema'
Package not installed.
fix
Run 'npm install get-schema' in your project directory.
TypeError: callback is not a function
Calling schema.get, getColumns, or getCreateTypes without providing a callback.
fix
Pass a function as the second argument: schema.get('table', function(err, result) { ... }).
Upgrade
Version history
0.1.11latest on npm
Audit
Dependencies
pgrequiredRequired for PostgreSQL/Redshift client connection.
Agent activity
6 hits · last 30 days
node
6
Resources
get-schema — npm install get-schema · libregistry