Registry / database / db-meta

db-meta

JSON →
library0.5.1jsnpmunverified

db-meta is a JavaScript library for extracting relational database metadata (tables, columns, data types, nullability, primary keys, default values, version) from PostgreSQL, MySQL, and SQLite3. Version 0.5.1 is the current stable release, with irregular updates. It abstracts over database-specific drivers (pg, mysql, sqlite3) using a unified callback-based API. Unlike ORM tools, it focuses purely on schema introspection without query building or object mapping. Requires Node.js >=0.6 and manual installation of the appropriate database driver.

databaseserialization
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CommonJS only; no ESM or default export available.

const dbmeta = require('db-meta')

db-meta exports a single function, not a class or object.

dbmeta('pg', { database: 'test' }, function(err, meta) { meta.getVersion(function(err, version) { ... }); });

Table objects are plain objects with methods like getName(), not classes.

meta.getTables(function(err, tables) { tables.forEach(function(table) { console.log(table.getName()); }); });

Shows how to connect to PostgreSQL, retrieve database version, list all user tables, and inspect columns for a specific table using callbacks.

const dbmeta = require('db-meta'); dbmeta('pg', { database: 'test' }, function(err, meta) { if (err) return console.error(err); meta.getVersion(function(err, version) { if (err) return console.error(err); console.log('PostgreSQL version:', version); }); meta.getTables(function(err, tables) { if (err) return console.error(err); tables.forEach(function(table) { console.log('Table:', table.getName()); }); }); meta.getColumns('tablename', function(err, columns) { if (err) return console.error(err); columns.forEach(function(col) { console.log(col.getName(), col.getDataType(), col.isNullable()); }); }); });
Debug
Known footguns
gotchaYou must install the database driver (pg, mysql, or sqlite3) separately. They are not included as dependencies.
breakingThe callback for getTables, getColumns, and other methods follows (err, result) pattern, but older examples may omit the error parameter.
deprecatedThe API does not support Promises or async/await. Only callbacks are available.
breakingIn version 0.5.0, the driver option 'pg' changed from 'postgres' to 'pg'. Using 'postgres' will cause an error.
gotchaThe options object may include a 'connection' key to pass an existing database connection. Not all drivers support this.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
15 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
bingbot
1
bytedance
1
Resources