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
Copy file name to clipboardExpand all lines: README.md
+15-14Lines changed: 15 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -3,31 +3,33 @@
3
3
This library is a implementation of the PostgreSQL backend/frontend protocol in javascript.
4
4
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).
5
5
6
-
This library allows for the correct handling of prepared queries.
6
+
This library allows for the correct handling of server-side prepared queries.
7
7
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.
9
9
10
10
All code is available under the terms of the MIT license, unless otherwise noted (md5.js)
11
11
12
+
(c) 2010, Tim Caswell, Aurynn Shaw.
13
+
12
14
## Example use
13
15
14
16
var sys = require("sys");
15
-
var pg = require("postgres");
17
+
var pg = require("postgres-pure");
16
18
17
19
var db = new pg.connect("pgsql://test:12345@localhost:5432/template1");
18
20
db.query("SELECT * FROM sometable", function (data) {
19
-
sys.p(data);
21
+
console.log(data);
20
22
});
21
23
db.close();
22
24
23
25
## Example use of Parameterized Queries
24
26
25
27
var sys = require("sys");
26
-
var pg = require("postgres");
28
+
var pg = require("postgres-pure");
27
29
28
30
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);
31
33
});
32
34
db.close();
33
35
@@ -37,10 +39,9 @@ All code is available under the terms of the MIT license, unless otherwise noted
37
39
var pg = require("postgres");
38
40
39
41
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) {
0 commit comments