-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.js
48 lines (45 loc) · 961 Bytes
/
database.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
const database = [
{
id: 1,
username: 'kurt',
password: '$2a$12$qUsfQCSJKLol5erObE4UYuBccPZ6CdAELn1e2fzpcc1SqllzQPVhS',
info: {
name: 'Kurt Russelle Marmol',
age: 19
}
},
{
id: 2,
username: 'juan',
password: '$2a$12$.02SmHE04uDg7uchHVTk3.GDsnyxi3FnH5r4M5/6IOPAincmhROCS',
info: {
name: 'Juan Luna',
age: 18
}
},
{
id: 3,
username: 'rizal',
password: '$2a$12$9FPRuOOripjgy5nR2.IQjeeRqdkrLe6DdISJI17mxozlTFngU4pzW',
info: {
name: 'Jose Rizal',
age: 21
}
}
]
// This function find username in database and return password
function findUsername(username) {
const result = database.filter(e => e.username === username);
return result.length === 0 ? 'user not found' : result;
}
function showInfos(id) {
const result = database.filter(e => {
return e.id === id;
})
return result;
}
module.exports = {
database,
findUsername,
showInfos
}