-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.go
41 lines (34 loc) · 1.4 KB
/
user.go
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
package models
import (
"github.com/kiranbhalerao123/gotter/utils"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type User struct {
ID string `json:"id,omitempty" bson:"_id,omitempty"`
Email string `json:"email" bson:"email"`
UserName string `json:"username" bson:"username"`
Password string `json:"-" bson:"password,omitempty"`
Posts []primitive.ObjectID `json:"posts,omitempty" bson:"posts"`
Following []primitive.ObjectID `json:"following,omitempty" bson:"following"`
Followers []primitive.ObjectID `json:"followers,omitempty" bson:"followers"`
}
type Author struct {
ID string `json:"id,omitempty" bson:"_id,omitempty"`
UserName string `json:"username" bson:"username"`
}
type #Inputs struct {
Email string `json:"email" bson:"email" valid:"email"`
UserName string `json:"username" bson:"username" valid:"length(3|30)"`
Password string `json:"password" bson:"password,omitempty" valid:"length(6|30)"`
}
type LoginInputs struct {
Email string `json:"email" bson:"email" valid:"email"`
Password string `json:"password" bson:"password,omitempty" valid:"length(6|30)"`
}
type UpdateInputs struct {
UserName string `json:"username" bson:"username" valid:"length(3|30)"`
Password string `json:"password" bson:"password,omitempty" valid:"length(3|30)"`
}
func (i #Inputs) Validate() error {
return utils.Validator(i)
}