model

package
v0.0.0-...-398d8f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID        uint64    `json:"id"`
	UserID    uint64    `json:"user_id" db:"user_id"`
	PhotoID   uint64    `json:"photo_id" db:"photo_id"`
	Message   string    `json:"message"`
	User      User      `json:"user"`
	Photo     Photo     `json:"photo"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

type CommentCreationRequest

type CommentCreationRequest struct {
	Message string `json:"message" binding:"required"`
	UserID  uint64 `json:"user_id"`
	PhotoID uint64 `json:"photo_id" binding:"required"`
}

func (CommentCreationRequest) ExistValidation

func (ccr CommentCreationRequest) ExistValidation(db *sqlx.DB) error

type CommentUpdateRequest

type CommentUpdateRequest struct {
	Message string `json:"message"`
}

type Photo

type Photo struct {
	ID        uint64    `json:"id"`
	Title     string    `json:"title"`
	Caption   string    `json:"caption"`
	PhotoURL  string    `json:"photo_url" db:"photo_url"`
	UserID    uint64    `json:"user_id" db:"user_id"`
	User      User      `json:"user"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

type PhotoCreationRequest

type PhotoCreationRequest struct {
	UserID   uint64
	Title    string `json:"title" binding:"required"`
	Caption  string `json:"caption"`
	PhotoURL string `json:"photo_url" binding:"required"`
}

type PhotoUpdateRequest

type PhotoUpdateRequest struct {
	UserID   uint64
	Title    string `json:"title" binding:"required"`
	Caption  string `json:"caption"`
	PhotoURL string `json:"photo_url" binding:"required"`
}

type SocialMedia

type SocialMedia struct {
	ID             uint64    `json:"id"`
	Name           string    `json:"name"`
	SocialMediaURL string    `json:"social_media_url" db:"social_media_url"`
	UserID         uint64    `json:"user_id" db:"user_id"`
	User           User      `json:"user"`
	CreatedAt      time.Time `json:"created_at" db:"created_at"`
	UpdatedAt      time.Time `json:"updated_at" db:"updated_at"`
}

type SocialMediaCreationRequest

type SocialMediaCreationRequest struct {
	Name           string `json:"name" binding:"required"`
	SocialMediaURL string `json:"social_media_url" binding:"required""`
	UserID         uint64 `json:"user_id"`
}

type SocialMediaUpdateRequest

type SocialMediaUpdateRequest struct {
	Name           string `json:"name"`
	SocialMediaURL string `json:"social_media_url"`
}

type User

type User struct {
	ID        uint64    `json:"id"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	Password  string    `json:"-"`
	Age       int       `json:"age"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Model representation of data from database

func (User) VerifyPassword

func (u User) VerifyPassword(password string) bool

VerifyPassword checks whether the password given matches with the hashed one

type UserCreationRequest

type UserCreationRequest struct {
	Username string `json:"username" binding:"required"`
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required,min=6"`
	Age      int    `json:"age" binding:"required,min=9"`
}

Struct for user registration request

func (UserCreationRequest) HashedPassword

func (ucr UserCreationRequest) HashedPassword() string

HashedPassword returns bcrypt-hashed password in string

func (UserCreationRequest) UniqueValidation

func (ucr UserCreationRequest) UniqueValidation(db *sqlx.DB) error

UniqueValidation makes sure the supplied fields is unique in the database

type UserLoginRequest

type UserLoginRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

Struct for user login request

type UserUpdateRequest

type UserUpdateRequest struct {
	Username string `json:"username" binding:"required"`
	Email    string `json:"email" binding:"required,email"`
	// contains filtered or unexported fields
}

Struct for user update request

func (*UserUpdateRequest) SetUser

func (uur *UserUpdateRequest) SetUser(user User)

SetUser sets user that is being updated to the struct

func (UserUpdateRequest) UniqueValidation

func (uur UserUpdateRequest) UniqueValidation(db *sqlx.DB) error

UniqueValidation makes sure the supplied fields is unique in the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL