Skip to content

Commit 7abae81

Browse files
author
Aurynn Shaw
committed
Update the README with more accurate/complete documentation.
1 parent b137206 commit 7abae81

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33
This library is a implementation of the PostgreSQL backend/frontend protocol in javascript.
44
It uses the node.js tcp and event libraries. A javascript md5 library is included for servers that require md5 password hashing (this is default).
55

6-
This library allows for the correct handling of prepared queries.
6+
This library allows for the correct handling of server-side prepared queries.
77

8-
If you wish to nest DB calls, db.close must be in the deepest callback, or all statements that occur inside of callbacks deeper than the callback which handles db.close will not be executed.
8+
Nested DB calls will be executed in the order of definition.
99

1010
All code is available under the terms of the MIT license, unless otherwise noted (md5.js)
1111

12+
(c) 2010, Tim Caswell, Aurynn Shaw.
13+
1214
## Example use
1315

1416
var sys = require("sys");
15-
var pg = require("postgres");
17+
var pg = require("postgres-pure");
1618

1719
var db = new pg.connect("pgsql://test:12345@localhost:5432/template1");
1820
db.query("SELECT * FROM sometable", function (data) {
19-
sys.p(data);
21+
console.log(data);
2022
});
2123
db.close();
2224

2325
## Example use of Parameterized Queries
2426

2527
var sys = require("sys");
26-
var pg = require("postgres");
28+
var pg = require("postgres-pure");
2729

2830
var db = new pg.connect("pgsql://test:12345@localhost:5432/template1");
29-
db.query("SELECT * FROM yourtable WHERE id = ?", [1], function (data) {
30-
sys.p(data);
31+
db.query("SELECT * FROM yourtable WHERE id = ?", 1, function (data) {
32+
console.log(data);
3133
});
3234
db.close();
3335

@@ -37,10 +39,9 @@ All code is available under the terms of the MIT license, unless otherwise noted
3739
var pg = require("postgres");
3840

3941
var db = new pg.connect("pgsql://test:12345@localhost:5432/template1");
40-
41-
var stmt = db.prepare("SELECT * FROM yourtable WHERE id = ?");
42-
43-
stmt.execute([1], function (d) {
44-
sys.p(d);
45-
db.close();
46-
});
42+
db.prepare("SELECT * FROM yourtable WHERE id = ?", function (stmt) {
43+
stmt.execute(1, function (rs) {
44+
console.log(rs[0]);
45+
});
46+
});
47+
db.close();

0 commit comments

Comments
 (0)