Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 651 Bytes

README.md

File metadata and controls

17 lines (12 loc) · 651 Bytes

pegsocket.js - WebSocket driver for PostgreSQL

For making SQL queries directly from the browser to a pg database. Because why not!

Usage:

import pegsocket from './pegsocket.js'

const pg = await pegsocket({ url: 'ws://example.com:15432', database: 'web', user: 'browser' });
const result = await pg.query("select 'Hello ' || $1 || '!' msg", ['world']);
=> { rows:[{ msg: "Hello world!" }], updated: 0 }

PostgreSQL server configuration

  • Expose pg port as WebSocket endpoint with e.g., pg_websocket.
  • Configure scram-sha-256 or trust authentication for a db user in pg_hba.conf.