models

package
v0.0.0-...-fd985a4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateUser

func ValidateUser(user *User) error

ValidateUser validates the user struct based on the defined tags.

Types

type User

type User struct {
	ID       uint   `json:"id" gorm:"primaryKey"`
	Username string `json:"username" gorm:"unique;not null" validate:"required,min=3,max=50"`
	Email    string `json:"email" gorm:"unique;not null" validate:"required,email"`
}

User represents the structure of a user in the application.

func NewUser

func NewUser(username, email string) *User

NewUser creates a new User instance with the provided data.

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

UserRepository represents a data access object for user-related operations.

func NewUserRepository

func NewUserRepository(db *gorm.DB) *UserRepository

NewUserRepository creates a new instance of UserRepository.

func (*UserRepository) CreateUser

func (ur *UserRepository) CreateUser(user *User) error

CreateUser saves a new user to the database.

func (*UserRepository) GetUserByID

func (ur *UserRepository) GetUserByID(userID uint) (*User, error)

GetUserByID retrieves a user by ID from the database.

Jump to

Keyboard shortcuts

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