@robinpath/postgres
0.1.1PublicPostgreSQL client with connection pooling, parameterized queries, transactions, RETURNING, and LISTEN/NOTIFY
@robinpath/postgres
PostgreSQL client with connection pooling, parameterized queries, transactions, RETURNING, and LISTEN/NOTIFY
Why use this module?
The postgres module lets you:
- Execute SQL query
- Execute query returning single row
- Insert row with RETURNING
- Insert multiple rows
- Update rows with RETURNING
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/postgres
Quick Start
1. Set up credentials
postgres.connect {"host": "localhost", "user": "postgres", "database": "mydb"}
2. Execute SQL query
postgres.query "SELECT * FROM users WHERE id = $1" [1]
Available Functions
| Function | Description |
|---|---|
postgres.connect | Connect to PostgreSQL |
postgres.query | Execute SQL query |
postgres.queryOne | Execute query returning single row |
postgres.insert | Insert row with RETURNING |
postgres.insertMany | Insert multiple rows |
postgres.update | Update rows with RETURNING |
postgres.remove | Delete rows with RETURNING |
postgres.transaction | Execute in transaction |
postgres.tables | List tables in schema |
postgres.describe | Describe table columns |
postgres.count | Count rows |
postgres.listen | Listen for NOTIFY events |
postgres.close | Close connection pool |
postgres.closeAll | Close all pools |
Examples
Execute SQL query
postgres.query "SELECT * FROM users WHERE id = $1" [1]
Execute query returning single row
postgres.queryOne "SELECT * FROM users WHERE id = $1" [1]
Insert row with RETURNING
postgres.insert "users" {"name": "Alice"}
Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/postgres";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
postgres.connect {"host": "localhost", "user": "postgres", "database": "mydb"}
postgres.query "SELECT * FROM users WHERE id = $1" [1]
`);
Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/mysql— MySQL module for complementary functionality@robinpath/mongo— Mongo module for complementary functionality@robinpath/redis— Redis module for complementary functionality@robinpath/supabase— Supabase module for complementary functionality@robinpath/firebase— Firebase module for complementary functionality
License
MIT
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | yesterday |
Related Modules
@robinpath/chart
Generate chart images (PNG/JPEG) using Chart.js. Supports bar, line, pie, doughnut, scatter, radar, polarArea, and bubble charts with auto-coloring and customizable titles, legends, and dimensions.
@robinpath/firebase
Firebase module for RobinPath.
@robinpath/graph
Graph data structures with BFS, DFS, Dijkstra's shortest path, topological sort, cycle detection, and connectivity
@robinpath/hotjar
Hotjar module for RobinPath.
$ robinpath install @robinpath/postgres
