-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmethods.go
More file actions
40 lines (33 loc) · 764 Bytes
/
methods.go
File metadata and controls
40 lines (33 loc) · 764 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
36
37
38
39
40
package main
import "fmt"
func FindUser(email string) (*User, error) {
var u User
err := db.Model(&User{}).Where("email = ?", email).Find(&u)
if err.Error != nil {
return nil, err.Error
}
return &u, nil
}
func FindUserKey(key string) (*User, error) {
var u User
err := db.Model(&User{}).Where("key = ?", key).Find(&u)
if err.Error != nil {
return nil, err.Error
}
return &u, nil
}
func (u *User) Create() error {
e := db.Model(&User{}).Create(u)
return e.Error
}
func (u *User) Update() error {
e := db.Model(&User{}).Update(u)
return e.Error
}
func (u *User) Delete() error {
e := db.Model(&User{}).Delete(u)
return e.Error
}
func (u *User) ConfirmLink() string {
return fmt.Sprintf("https://emailer.statping.com/confirm/%s", u.Key)
}