Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #18

Open
wants to merge 1 commit into
base: public
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 35 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
# Livetex-Node-Pg

Multithreaded Postgres driver for Node-JS built with `libpq` and `libjemalloc`.
> Multithreaded Postgres driver for Node-JS built with `libpq` and `libjemalloc`.

####Install via npm:
npm install livetex-node-pg
#### Install via npm:
```bash
npm install livetex-node-pg
````

## Examples

### Simple query processing

```js
var pg = require('livetex-node-pg');
const pg = require("livetex-node-pg");

pg.init(20, {
'user': 'postgres',
'dbname': 'postgres',
'hostaddr': '127.0.0.1',
'password': 'postgres'
"user": "postgres",
"dbname": "postgres",
"hostaddr": "127.0.0.1",
"password": "postgres"
});

pg.exec("SELECT 1 AS value", function(table) {
console.log('Result table:', table);
pg.exec("SELECT 1 AS value", table => {
console.log("Result table:", table);
}, console.error);

pg.exec("SELECT 2 AS another_value", function(table) {
console.log('Result table:', table);
pg.exec("SELECT 2 AS another_value", table => {
console.log("Result table:", table);
}, console.error);
```

Expand All @@ -35,17 +37,17 @@ any other method.
### Process destroying

```js
var pg = require('livetex-node-pg');
const pg = require("livetex-node-pg");

pg.init(20, {
'user': 'postgres',
'dbname': 'postgres',
'hostaddr': '127.0.0.1',
'password': 'postgres'
"user": "postgres",
"dbname": "postgres",
"hostaddr": "127.0.0.1",
"password": "postgres"
});

pg.exec("SELECT 1 AS value", function(table) {
console.log('Result table:', table);
pg.exec("SELECT 1 AS value", table => {
console.log("Result table:", table);
}, console.error);

pg.destroy();
Expand All @@ -56,28 +58,28 @@ Nothing happen after `destroy` call.
### Prepared queries

```js
var pg = require('livetex-node-pg');
var preparedQuery = "SELECT $word1 AS word1, $word2 AS word2";
const pg = require("livetex-node-pg");
const preparedQuery = "SELECT $word1 AS word1, $word2 AS word2";

pg.init(20, {
'user': 'postgres',
'dbname': 'postgres',
'hostaddr': '127.0.0.1',
'password': 'postgres'
"user": "postgres",
"dbname": "postgres",
"hostaddr": "127.0.0.1",
"password": "postgres"
});

pg.execPrepared(preparedQuery, {
'word1': 'hello',
'word2': 'world'
}, function(table) {
console.log('Result table:', table);
"word1": "hello",
"word2": "world"
}, table => {
console.log("Result table:", table);
}, console.error);

pg.execPrepared(preparedQuery, {
'word1': 'bye',
'word2': 'bye'
}, function(table) {
console.log('Result table:', table);
"word1": "bye",
"word2": "bye"
}, table => {
console.log("Result table:", table);
}, console.error);
```

Expand Down