You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -30,55 +35,8 @@ db.query('SELECT id FROM user')
30
35
31
36
## Documentation
32
37
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
-
returninsert1.concat(insert2);
77
-
})
78
-
.subscribe((row) =>console.log(row));
79
-
```
80
-
81
-
No data will be emitted if any query in a transaction fails.
Before using this library or reading its source code, you should know [Reactive Programming & RxJS](http://reactivex.io/intro.html).
90
48
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.
0 commit comments