Skip to content
brianc edited this page Nov 1, 2010 · 66 revisions

Basically a facade on top of the connection to provide a much more user friendly, "node style" interface for doing all the lovely things you like with PostgreSQL.

Constructor


new Client(object config) : Client

Creates a new instance of a Client configured via supplied configuration object. In normal instantiation the client will not be connected automatically.

parameters
  • config: [object] can contain any of the following optional properties
    • user: [string]
      • default value: null
      • PostgreSQL user
    • database: [string]
      • default value: null
      • database to use when connecting to PostgreSQL server
    • password: [string]
      • default value: null
      • user's password for PostgreSQL server
    • port: [number]
      • default value: 5432
      • port to use when connecting to PostgreSQL server
      • will support unix domain sockets in future
      • used to initialize underlying net.Stream()
    • host: [string]
      • default value: null
      • host address of PostgreSQL server
      • used to initialize underlying net.Stream()
    • connection: [Connection]
      • default value: new Connection(config)
      • the Connection object used by client. Only really provided as a config option to aid in testing. Will be used in the future when connection pooling is implemented
example
    var client = new Client({
      user: 'brianc',
      password: 'boom!'
      database: 'test'
      host: 'example.com'
      port: 5313
    });

Methods


connect() : null

Initializes underlying net.Stream() and startup communication with PostgreSQL server. Once the connection is finished, the Client emits the connect event.

end() : null

Immediately sends a termination message to the PostgreSQL server and closes the underlying net.Stream().

query(string text) : Query

Clone this wiki locally