Giter Site home page Giter Site logo

nopegres's Introduction

nopegres

zero dependency Node/Javascript driver for Postgres

Why is this called nopegres?

  • 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

Test

npm test

Use

  • 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'

Client (Event Emitter)

Events
  • statusChange - emitted every time Client.status changes
    • statuses: connecting | connected | authenticating | readyForQuery | querying | disconnected

QueryResult (Event Emitter)

Events
  • row - emits a result row from the query
  • complete - query has completed
  • done - no more messages will be received on this Emitter, safe to drop all listeners
  • error - emitted on server error, emits an error message string

nopegres's People

Contributors

alexcusack avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.