-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.model.js
More file actions
28 lines (25 loc) · 748 Bytes
/
Copy pathusers.model.js
File metadata and controls
28 lines (25 loc) · 748 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
import connection from '../db/connect_mysql.js'
//User object create
class User {
constructor(user) {
this.name = user.name,
this.email = user.email,
this.password = user.password,
this.token = user.token,
this.type = user.type,
this.created_at = new Date()
this.updated_at = new Date()
}
static async findOne(email, result) {
connection.query("SELECT * FROM users WHERE email = ?", email, (err, res) => {
if (err) {
console.log("error: ", err)
result(err, null)
} else {
console.log(res)
result(null, res[0])
}
})
}
}
export default User