This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
64 lines (54 loc) · 1.89 KB
/
app.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var sqlite3 = require('sqlite3');
var db = new sqlite3.Database('./Northwind.sl3');
db.serialize(function () {
db.run('', function () {
console.log('==========');
console.log('Categories');
console.log('==========');
});
db.each('SELECT * FROM Categories', function (err, row) {
console.log(row.Description.toString());
});
db.run('', function () {
console.log('========');
console.log('Products');
console.log('========');
});
db.each('SELECT * FROM Products ' +
'INNER JOIN Categories ' +
'ON Products.CategoryID = Categories.CategoryID ' +
'LIMIT 10', function (err, row) {
console.log(row.ProductName + ' is a ' + row.CategoryName);
});
db.run('', function () {
console.log('====================');
console.log('Employee Supervisors')
console.log('====================');
})
db.each('SELECT Employees.LastName AS EmployeeLastName, Supervisors.LastName AS SupervisorLastName ' +
'FROM Employees ' +
'LEFT OUTER JOIN Employees AS Supervisors ' +
'ON Employees.ReportsTo = Supervisors.EmployeeID', function (err, row) {
if (row.SupervisorLastName) {
console.log(row.EmployeeLastName + "'s supervisor is " + row.SupervisorLastName);
} else {
console.log(row.EmployeeLastName + ' has no supervisor');
}
});
db.run('', function () {
console.log('===========================');
console.log('New CategoryFavorites Table')
console.log('===========================');
});
db.run('', function () {
console.log('========================================');
console.log('Insert [Data into] CategoryFavorites Table')
console.log('========================================');
});
db.run('', function () {
console.log('===========================');
console.log('New CategoryFavorites Table')
console.log('===========================');
});
db.close();
});