Skip to content

Commit 19210ee

Browse files
authored
Merge branch 'master' into release
2 parents 698bb62 + 65faa53 commit 19210ee

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## 3.0.0
2+
3+
Thanks to @billwashere, we upgraded to a more modern version of `pg` (4.5.1 ->
4+
7.4.1), which means that the way the database information is provided has
5+
changed. Previously, you could pass a URL to sharedb-postgres, like:
6+
7+
```js
8+
const db = require('sharedb-postgres')('postgres://localhost/mydb');
9+
```
10+
11+
This is no longer supported, and you must instead pass a config object:
12+
13+
```js
14+
const db = require('sharedb-postgres')({host: 'localhost', database: 'mydb'});
15+
```
16+
17+
See the [node-postgres](https://node-postgres.com/features/connecting)
18+
documentation for more details about what can be passed in the config object.
19+
Additionally, if no object is provided, `pg` will use the same environment
20+
variables as `libpq` (`PGUSER`, `PGHOST` and so on).

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,15 @@ PGUSER=dbuser PGPASSWORD=secretpassword PGHOST=database.server.com PGDATABASE=m
5151
Example using an object
5252

5353
```js
54-
var db = require('sharedb-postgres')({
55-
user: 'dbuser',
56-
host: 'database.server.com',
57-
database: 'mydb',
58-
password: 'secretpassword',
59-
port: 5433,
60-
});
54+
var db = require('sharedb-postgres')({host: 'localhost', database: 'mydb'});
6155
var backend = require('sharedb')({db: db})
6256
```
6357

6458
## Error codes
6559

6660
PostgreSQL errors are passed back directly.
61+
62+
## Changelog
63+
64+
Note that version 3.0.0 introduces breaking changes in how you specify
65+
connection parameters. See the [changelog](CHANGELOG.md) for more info.

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ function PostgresDB(options) {
99

1010
this.closed = false;
1111

12-
this.pg_config = options;
13-
this.pool = new pg.Pool(this.pg_config)
14-
12+
this.pool = new pg.Pool(options);
1513
};
1614
module.exports = PostgresDB;
1715

1816
PostgresDB.prototype = Object.create(DB.prototype);
1917

2018
PostgresDB.prototype.close = function(callback) {
2119
this.closed = true;
22-
this.pool.end()
20+
this.pool.end();
2321

2422
if (callback) callback();
2523
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sharedb-postgres",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "PostgreSQL adapter for ShareDB",
55
"main": "index.js",
66
"scripts": {
@@ -14,4 +14,4 @@
1414
"pg": "^7.4.1",
1515
"sharedb": "^1.0.0-beta.7"
1616
}
17-
}
17+
}

0 commit comments

Comments
 (0)