forked from kirti/node-express-swagger-crud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.js
50 lines (47 loc) · 1 KB
/
user.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
export const getUserList = () => {
return [
{
id: 1,
isPublic: true,
name: 'user1',
companies: ['com1', 'com2', 'com3'],
books: [{
name: 'book1',
amount: 1,
},
{
name: 'book2',
amount: 200,
}
]
},
{
id: 2,
isPublic: true,
name: 'kk',
companies: ['com1', 'com2', 'com3'],
books: [
{
name: 'kk2',
amount: 1,
},
{
name: 'kk2',
amount: 200,
}
]
}
]
}
export const findUserById = (id) =>{
const users = getUserList()
const userFound = users.filter((user) => {
if (user.id === id) {
return user
}
});
if(userFound.length>0){
return userFound
}
return false
}