-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (42 loc) · 1.19 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
const mysql = require('mysql');
const inq = require('inquirer');
const Table = require('easy-table');
const customerView = require('./Customer');
const managerView = require('./Manager');
const supervisorView = require('./Supervisor');
let connection = mysql.createConnection({
host: 'localhost',
user: 'root',
database: 'bamazon_db'
});
connection.connect((err) => {
initialize();
})
let initialize = () => {
inq.prompt([
{
'type': 'list',
'message': 'Customer, Admin, Supervisor?',
'name': 'userType',
'choices': ['Customer', 'Manager', 'Supervisor']
}
]).then((answers) => {
console.log(answers.userType)
switch (answers.userType) {
case 'Customer':
connection.query('Select * From products', (err, res) => {
customerView();
connection.end();
})
break;
case 'Manager':
managerView();
connection.end();
break;
case 'Supervisor':
supervisorView();
connection.end();
break;
}
});
};