Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateUser ¶
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.
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.
Click to show internal directories.
Click to hide internal directories.