-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusers.go
More file actions
35 lines (29 loc) · 819 Bytes
/
users.go
File metadata and controls
35 lines (29 loc) · 819 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
29
30
31
32
33
34
35
package main
type User struct {
Id int64 `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
AvatarUrl string `json:"avatar_url"`
ProfileUrl string `json:"profile_url"`
Email string `json:"email"`
Joined string `json:"joined"`
Raw RawJson `json:"raw"`
AccessToken string `json:"-"`
TimeStamp
}
type UserList []User
func (u *UserList) List() error {
_, err := dbmap.Select(u, "SELECT * FROM USERS ORDER BY CreatedAt DESC")
return err
}
func (u *User) Create() error {
// run the UpdateTime ethod on the user model
u.UpdateTime()
// run the DB insert function
err := dbmap.Insert(u)
return err
}
func (u *User) GetByUsername(n string) error {
err := dbmap.SelectOne(u, "SELECT * FROM users WHERE username=$1", n)
return err
}