PostgreSQL database connection string or config object
Close the current database connection.
Run a query with optional values.
This function supports the query formatting of pg and you can construct the query like
pgrx.query('SELECT id FROM user WHERE name = $1::text', ['Tom']);
It will return an observable that emits every row of the query result.
Query SQL
Optional query parameters
Observable
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.
pgrx.tx((t) => {
const insert1 = t.query('INSERT INTO user (name) VALUES ($1::text) RETURNING id;', ['Tom']);
const insert2 = t.query('INSERT INTO user (name) VALUES ($1::text) RETURNING id;', ['Joe']);
return insert1.concat(insert2);
})
.subscribe((row) => console.log(row));
No data will be emitted if any query in a transaction fails.
A callback function that returns an observable for database operation.
Observable
Generated using TypeDoc
Initalize a database connection.
It can be initialized with a database url like
or a crednetial object: