Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 54422db952a9662c6f8757bdf29456daee121a38 1 parent 02564ee
@aslakhellesoy aslakhellesoy authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/server/db/pg.coffee
View
4 src/server/db/pg.coffee
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.