Skip to content

Commit 3afd7cc

Browse files
committed
docs.
1 parent 3756365 commit 3afd7cc

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ leaving the burden of all extra checks to the library.
321321
The library supports named parameters in query formatting, with the syntax of `$*propName*`, where `*` is any of the following open-close
322322
pairs: `{}`, `()`, `<>`, `[]`, `//`
323323

324-
```javascript
324+
```js
325325
db.query('select * from users where name=${name} and active=$/active/', {
326326
name: 'John',
327327
active: true
@@ -380,7 +380,7 @@ In PostgreSQL stored procedures are just functions that usually do not return an
380380
Suppose we want to call function **findAudit** to find audit records by `user_id` and maximum timestamp.
381381
We can make such call as shown below:
382382
383-
```javascript
383+
```js
384384
db.func('findAudit', [123, new Date()])
385385
.then(function (data) {
386386
console.log(data); // printing the data returned
@@ -419,7 +419,8 @@ This allows usage of your own custom types as formatting parameters for the quer
419419
overriding formatting for standard object types, such as `Date` and `Array`.
420420

421421
**Example: your own type formatting**
422-
```javascript
422+
423+
```js
423424
function Money(m) {
424425
this.amount = m;
425426
this.formatDBType = function () {
@@ -430,7 +431,8 @@ function Money(m) {
430431
```
431432
432433
**Example: overriding standard types**
433-
```javascript
434+
435+
```js
434436
Date.prototype.formatDBType = function () {
435437
// format Date as a local timestamp;
436438
return this.getTime();
@@ -469,7 +471,7 @@ with `::uuid[]` appended at the end of the variable.
469471
470472
You can implement your own presentation for UUID that does not require extra casting:
471473
472-
```javascript
474+
```js
473475
function UUID(value) {
474476
this.uuid = value;
475477
this._rawDBType = true; // force raw format on output;
@@ -519,6 +521,7 @@ db.one(sqlFindUser, {id: 123})
519521
```
520522
521523
File `findUser.sql`:
524+
522525
```sql
523526
/*
524527
multi-line comment
@@ -548,7 +551,7 @@ A task represents a shared connection to be used within a callback function. The
548551
549552
A transaction, for example, is just a special type of task, wrapped in `CONNECT->COMMIT/ROLLBACK`.
550553
551-
```javascript
554+
```js
552555
db.task(function (t) {
553556
// `t` and `this` here are the same;
554557
// execute a chain of queries;
@@ -678,7 +681,7 @@ function source(index, data, delay) {
678681
}
679682

680683
db.tx(function (t) {
681-
// t = this;
684+
// `t` and `this` here are the same;
682685
return this.sequence(source);
683686
})
684687
.then(function (data) {
@@ -753,7 +756,7 @@ If you prefer writing asynchronous code in a synchronous manner, you can impleme
753756
754757
```js
755758
function * getUser(t) {
756-
// t = this;
759+
// `t` and `this` here are the same;
757760
let user = yield this.oneOrNone('select * from users where id = $1', 123);
758761
return yield user || this.one('insert into users(name) values($1) returning *', 'John');
759762
}
@@ -810,7 +813,8 @@ By default, **pg-promise** uses ES6 Promise. If your version of NodeJS doesn't s
810813
or you want a different promise library to be used, set this property to the library's instance.
811814
812815
Example of switching over to [Bluebird]:
813-
```javascript
816+
817+
```js
814818
var promise = require('bluebird');
815819
var options = {
816820
promiseLib: promise

0 commit comments

Comments
 (0)