ORM Playground
A lightweight ORM playground for PostgreSQL that helps you explore and understand your database schema.
Installation
npm install orm-playground
Usage
const { initPool, getTables, getTableSchema, disconnect } = require('orm-playground');
const pool = initPool('postgresql://user:password@localhost:5432/dbname');
async function listTables() {
try {
const tables = await getTables();
console.log('Available tables:', tables);
} catch (error) {
console.error('Error:', error);
}
}
async function getSchema(tableName) {
try {
const schema = await getTableSchema(tableName);
console.log(`Schema for ${tableName}:`, schema);
} catch (error) {
console.error('Error:', error);
}
}
async function cleanup() {
await disconnect();
}
async function main() {
await listTables();
await getSchema('users');
await cleanup();
}
main();
API Reference
initPool(connectionUrl: string): Pool
Initializes a new PostgreSQL connection pool.
getTables(): Promise<string[]>
Returns a list of all tables in the database.
getTableSchema(tableName: string): Promise<ColumnInfo[]>
Returns the schema information for a specific table.
disconnect(): Promise<void>
Closes the database connection pool.
License
MIT