Modules@robinpath/postgres

@robinpath/postgres

0.1.1Public

PostgreSQL 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

Category Functions Auth License

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

FunctionDescription
postgres.connectConnect to PostgreSQL
postgres.queryExecute SQL query
postgres.queryOneExecute query returning single row
postgres.insertInsert row with RETURNING
postgres.insertManyInsert multiple rows
postgres.updateUpdate rows with RETURNING
postgres.removeDelete rows with RETURNING
postgres.transactionExecute in transaction
postgres.tablesList tables in schema
postgres.describeDescribe table columns
postgres.countCount rows
postgres.listenListen for NOTIFY events
postgres.closeClose connection pool
postgres.closeAllClose 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

License

MIT

Versions (1)

VersionTagPublished
0.1.1latestyesterday
Install
$ robinpath install @robinpath/postgres
Version0.1.1
LicenseMIT
Unpacked Size5.7 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

data