Skip to content

Commit 62e4858

Browse files
authored
Support RxJS 6 (#11)
* support rxjs 6 * update ci * update documentation * 1.0.0
1 parent 7141905 commit 62e4858

16 files changed

+3908
-2563
lines changed

.babelrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 151 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ node_modules
3535
scripts/**/*.test.*
3636

3737
dist
38+
docs

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
test
22
config
3+
src
4+
docs

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ addons:
1313

1414
script:
1515
- npm test
16+
- npm run doc
1617

1718
env:
1819
- NODE_ENV=travis
20+
21+
deploy:
22+
provider: pages
23+
local-dir: docs
24+
github-token: $GITHUB_TOKEN
25+
skip-cleanup: true
26+
keep-history: true
27+
on:
28+
branch: master

README.md

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@
44

55
[![ReactiveX](http://reactivex.io/assets/Rx_Logo_S.png)](http://reactivex.io/)
66

7-
[RxJS 5](http://reactivex.io/) interface for PostgreSQL in node.js
7+
[RxJS](https://github.com/ReactiveX/rxjs) interface for PostgreSQL in node.js
88

99

1010
## Installation
1111

12-
1312
``` bash
1413
npm install pg-reactive
1514
```
1615

16+
If you are using RxJS v5, install a previous version:
17+
18+
``` bash
19+
npm install pg-reactive@^0.3.5
20+
```
21+
1722
## Example
1823

1924
``` javascript
20-
import pgrx from 'pg-reactive';
25+
import PgRx from 'pg-reactive';
2126

22-
let db = new pgrx('postgres://postgres@$localhost/tester');
27+
const db = new PgRx('postgres://postgres@$localhost/tester');
2328

2429
db.query('SELECT id FROM user')
2530
.map((row) => row.id)
@@ -30,55 +35,8 @@ db.query('SELECT id FROM user')
3035

3136
## Documentation
3237

33-
* `pgrx` Class
34-
35-
Database connection class. It can be initialized with a database url like
36-
37-
```
38-
pg://user:password@host:port/database
39-
```
40-
41-
or a crednetial object:
42-
43-
``` json
44-
{
45-
"user": "postgres",
46-
"database": "tester",
47-
"password": "",
48-
"host": "localhost",
49-
"port": 5432
50-
}
51-
```
52-
53-
* `pgrx.end()` Function
54-
55-
End the current database connection.
56-
57-
* `pgrx.query(sql[, values])` Function
58-
59-
Run a query with optional values. This function supports the query formating of [pg](https://github.com/brianc/node-postgres/wiki/Client#parameterized-queries) and you can construct the query like
60-
61-
``` javascript
62-
pgrx.query('SELECT id FROM user WHERE name = $1::text', ['Tom']);
63-
```
64-
65-
It will return an observable that emits every row of the query result.
66-
67-
* `pgrx.tx(callback)` Function
68-
69-
Run queries within a transaction. The callback function receives an object that has a `query()` function to run queries within the transaction and return an observable. To pass the data to the following operator, return an observable in the callback function.
70-
71-
``` javascript
72-
pgrx.tx((t) => {
73-
let insert1 = t.query('INSERT INTO user (name) VALUES ($1::text) RETURNING id;', ['Tom']);
74-
let insert2 = t.query('INSERT INTO user (name) VALUES ($1::text) RETURNING id;', ['Joe']);
75-
76-
return insert1.concat(insert2);
77-
})
78-
.subscribe((row) => console.log(row));
79-
```
80-
81-
No data will be emitted if any query in a transaction fails.
38+
* [latest (for RxJS 6)](https://haoliangyu.github.io/pg-reactive)
39+
* [v0.3.x (for RxJS 5)](https://github.com/haoliangyu/pg-reactive/blob/v0.3.5/README.md)
8240

8341
## TypeScript
8442

@@ -88,7 +46,7 @@ db.query('SELECT id FROM user')
8846

8947
Before using this library or reading its source code, you should know [Reactive Programming & RxJS](http://reactivex.io/intro.html).
9048

91-
`pg-reactive` wraps the low-level [pg](https://github.com/haoliangyu/pg-reactive) APIs and exposes a RxJS-compatible interface. The work of `pg-reactive` includes the following three aspects.
49+
`pg-reactive` wraps the low-level [pg](https://github.com/brianc/node-postgres) APIs and exposes a RxJS-compatible interface. The work of `pg-reactive` includes the following three aspects.
9250

9351
### Deferred Query
9452

0 commit comments

Comments
 (0)