Skip to content

Client.prototype.connect with callback #52

@booo

Description

@booo

What do you think about adding an optional callback function to the Client.prototype.connect function?

pg = require "pg"

client = new pg.Client "pg://postgres:testing@localhost/orm"

client.connect (error, client) ->
  if error then console.log error
  else
    console.log "connected (callback)"
    client.end()

client.on "connect", ->
  #never reached
  console.log "connected..."
  client.end()

client.on "error", (error) ->
  #only for errors afther connect event
  console.log error

I prepared a patch. Maybe you can take a look and tell me where the best place for test is.

Regards
Philipp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions