Skip to content

Commit 41e3d7f

Browse files
committed
Add documentation
1 parent 4137f64 commit 41e3d7f

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

README.markdown

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# PostgreSQL for Javascript
2+
3+
This library is a implementation of the PostgreSQL backend/frontend protocol in javascript.
4+
It uses the node.js tcp and event libraries. A javascript md5 library is included for servers that require md5 password hashing.
5+
6+
## Example use
7+
8+
include('md5.js');
9+
var postgres = require('postgres.js');
10+
11+
function onLoad() {
12+
var db = new postgres.Connection("database", "username", "password");
13+
db.query("SELECT * FROM sometable", function (data) {
14+
p(data);
15+
});
16+
db.close();
17+
}
18+
19+

postgres.js

-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
var DEBUG = 0;
32

43
include('util.js');
5-
include('md5.js');
64

75
function add_int(message, num) {
86
var part;
@@ -379,15 +377,4 @@ exports.Connection = function (database, username, password) {
379377
}
380378
};
381379

382-
function onLoad() {
383-
384-
var db = new exports.Connection("databasename", "username", "password");
385-
db.query("SELECT id FROM users LIMIT 1", p);
386-
db.query("SELECT id FROM users where id > 2 LIMIT 1", p);
387-
db.query("SELECT id FROM users WHERE id > 5 LIMIT 1", p);
388-
setTimeout(function () {
389-
db.query("SELECT * FROM users", p);
390-
db.close();
391-
}, 20);
392-
}
393380

sample.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include('md5.js');
2+
var postgres = require('postgres.js');
3+
4+
function onLoad() {
5+
var db = new postgres.Connection("database", "username", "password");
6+
db.query("SELECT * FROM sometable", function (data) {
7+
p(data);
8+
});
9+
db.close();
10+
}
11+
12+

0 commit comments

Comments
 (0)