forked from totaljs/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.js
More file actions
executable file
·38 lines (27 loc) · 846 Bytes
/
Copy pathdefault.js
File metadata and controls
executable file
·38 lines (27 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
exports.install = function() {
F.route('/', view_index);
};
function view_index() {
var self = this;
// definitions/mysql.js
// create a DB connection
DATABASE(function(err, connection){
if(err != null) {
self.throw500(err);
return;
}
// Table schema = { Id: Number, Age: Number, Name: String };
connection.query('SELECT * FROM users', function(err, rows) {
// Close connection
connection.release();
if (err != null) {
self.view500(err);
return;
}
// Shows the result on a console window
console.log(rows);
// Send rows as the model into the view
self.view('index', rows);
});
});
}