Permalink
Browse files

Let me pass in a pg.Client so I can use the same connection from my a…

…pp instead of creating a 2nd connection. Similar to #30 and #31.
  • Loading branch information...
aslakhellesoy committed Oct 23, 2012
1 parent 02564ee commit 54422db952a9662c6f8757bdf29456daee121a38
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/server/db/pg.coffee
View
@@ -27,6 +27,8 @@ pg = require('pg').native
defaultOptions =
schema: 'sharejs'
+ client: null # An optional instance of pg.Client
+ uri: null # An optional uri for connection
create_tables_automatically: true
operations_table: 'ops'
snapshot_table: 'snapshots'
@@ -37,7 +39,7 @@ module.exports = PgDb = (options) ->
options ?= {}
options[k] ?= v for k, v of defaultOptions
- client = new pg.Client options.uri
+ client = options.client or new pg.Client options.uri
client.connect()
snapshot_table = options.schema and "#{options.schema}.#{options.snapshot_table}" or options.snapshot_table

0 comments on commit 54422db

Please sign in to comment.