zero dependency Node/Javascript driver for Postgres
- Because the answer to 'does this do x', is likely 'nope'
- Client pooling? Nope.
- SSL? Nope.
- Automatic reconnects? Nope.
Wait, then why did you make this?
- For fun.
- ..But mostly to play with implementing a binary protocol and better understand of the Postgres API specifically
npm test
- Experiment with this library with a temporary postgres instance so any mistakes won't mess up your data
$ cd /tmp
$ initdb pgfiles
$ postgres -D pgfiles -h localhost -p 5433
- In a separate session:
$ cd path/to/nopegres
$ node
> pg = require('./index')
> conf = { port: 5433, user: process.env.USER, database: 'postgres', application_name: 'psql' }
> client = pg.createClient(conf)
Client {...}
> res = client.query('select x from values (1)')
QueryResult {...}
> res.on("row", (row) => console.log(row))
{ x: 1 }
> client.end()
> client.status
'disconnected'
statusChange
- emitted every timeClient.status
changes-
- statuses:
connecting | connected | authenticating | readyForQuery | querying | disconnected
- statuses:
row
- emits a result row from the querycomplete
- query has completeddone
- no more messages will be received on this Emitter, safe to drop all listenerserror
- emitted on server error, emits an error message string