Documentation ¶
Index ¶
- Constants
- Variables
- func Sanity(value string) string
- type DeleteUserInput
- type InsertUserInput
- type ListUserInput
- type SelectUsersInput
- type SelectUsersOutput
- type UpdateUserInput
- type User
- type UserInput
- type UserRepository
- func (r *UserRepository) Close() error
- func (r *UserRepository) Conn(ctx context.Context) (*sql.Conn, error)
- func (r *UserRepository) Delete(ctx context.Context, input *DeleteUserInput) error
- func (r *UserRepository) DriverName() string
- func (r *UserRepository) Insert(ctx context.Context, input *InsertUserInput) error
- func (r *UserRepository) PingContext(ctx context.Context) error
- func (r *UserRepository) Select(ctx context.Context, input *SelectUsersInput) (*SelectUsersOutput, error)
- func (r *UserRepository) SelectUserByEmail(ctx context.Context, email string) (*User, error)
- func (r *UserRepository) SelectUserByID(ctx context.Context, id uuid.UUID) (*User, error)
- func (r *UserRepository) Update(ctx context.Context, input *UpdateUserInput) error
- type UserRepositoryConfig
Constants ¶
const ( UsersFirstNameMinLength = 2 UsersFirstNameMaxLength = 255 UsersLastNameMinLength = 2 UsersLastNameMaxLength = 255 UsersEmailMinLength = 6 UsersEmailMaxLength = 255 UsersPasswordMinLength = 6 UsersPasswordMaxLength = 255 )
Variables ¶
var ( ErrInvalidDBConfiguration = errors.New("invalid database configuration. It is nil") ErrInvalidMaxPingTimeout = errors.New("invalid max ping timeout. It must be greater than 10 millisecond") ErrInvalidMaxQueryTimeout = errors.New("invalid max query timeout. It must be greater than 10 millisecond") ErrInvalidOTConfiguration = errors.New("invalid OpenTelemetry configuration. It is nil") ErrAtLeastOneFieldMustBeUpdated = errors.New("at least one field must be updated") ErrInputIsNil = errors.New("input is nil") ErrInvalidFilter = errors.New("invalid filter field") ErrInvalidSort = errors.New("invalid sort field") ErrInvalidFields = errors.New("invalid fields field") ErrInvalidLimit = errors.New("invalid limit field") ErrInvalidNextToken = errors.New("invalid nextToken field") ErrInvalidPrevToken = errors.New("invalid prevToken field") )
var ( ErrInvalidUserID = errors.New("invalid user ID. Must be a valid UUID") ErrInvalidUserFirstName = errors.New("invalid first name. Must be between " + fmt.Sprintf("%d and %d", UsersFirstNameMinLength, UsersFirstNameMaxLength) + " characters long") ErrInvalidUserLastName = errors.New("invalid last name. Must be between " + fmt.Sprintf("%d and %d", UsersLastNameMinLength, UsersLastNameMaxLength) + " characters long") ErrInvalidUserEmail = errors.New("invalid email. Must be between " + fmt.Sprintf("%d and %d", UsersEmailMinLength, UsersEmailMaxLength) + " characters long") ErrInvalidUserPassword = errors.New("invalid password. Must be between " + fmt.Sprintf("%d and %d", UsersPasswordMinLength, UsersPasswordMaxLength) + " characters long") ErrUserNotFound = errors.New("user not found") ErrUserIDAlreadyExists = errors.New("user ID already exists") ErrUserEmailAlreadyExists = errors.New("user email already exists") )
var ( // UserFilterFields is a list of valid fields for filtering users. UserFilterFields = []string{"id", "first_name", "last_name", "email", "disabled", "created_at", "updated_at"} // UserSortFields is a list of valid fields for sorting users. UserSortFields = []string{"id", "first_name", "last_name", "email", "disabled", "created_at", "updated_at"} // UserPartialFields is a list of valid fields for partial responses. UserPartialFields = []string{"id", "first_name", "last_name", "email", "disabled", "created_at", "updated_at"} )
Functions ¶
Types ¶
type DeleteUserInput ¶
DeleteUserInput represents the input for the DeleteUser method.
func (*DeleteUserInput) Validate ¶
func (ui *DeleteUserInput) Validate() error
Validate validates the DeleteUserInput.
type InsertUserInput ¶
type InsertUserInput UserInput
InsertUserInput represents the input for the CreateUser method.
func (*InsertUserInput) Validate ¶
func (ui *InsertUserInput) Validate() error
Validate validates the CreateUserInput.
type ListUserInput ¶
type ListUserInput struct { Sort string Filter string Fields []string Paginator paginator.Paginator }
ListUserInput represents the common input for the list user method.
func (*ListUserInput) Validate ¶
func (ui *ListUserInput) Validate() error
Validate validates the ListUserInput.
type SelectUsersInput ¶
type SelectUsersInput ListUserInput
SelectUsersInput represents the common input for the select user method.
func (*SelectUsersInput) Validate ¶ added in v0.0.11
func (ui *SelectUsersInput) Validate() error
Validate validates the SelectUsersInput.
type SelectUsersOutput ¶
SelectUsersOutput represents the output for the list user method.
type UpdateUserInput ¶
type UpdateUserInput struct { ID uuid.UUID FirstName *string LastName *string Email *string PasswordHash *string Disabled *bool UpdatedAt *time.Time }
UpdateUserInput represents the input for the UpdateUser method.
func (*UpdateUserInput) Validate ¶
func (ui *UpdateUserInput) Validate() error
Validate validates the UpdateUserInput.
type User ¶
type User struct { ID uuid.UUID FirstName string LastName string Email string PasswordHash string Disabled bool CreatedAt time.Time UpdatedAt time.Time SerialID int64 }
User represents a user entity used to model the data stored in the database.
type UserInput ¶
type UserInput struct { ID uuid.UUID FirstName string LastName string Email string PasswordHash string Disabled bool }
UserInput represents the common input for the user entity.
type UserRepository ¶ added in v0.0.11
type UserRepository struct {
// contains filtered or unexported fields
}
this implement repository.UserRepository UserRepository is a PostgreSQL store.
func NewUserRepository ¶ added in v0.0.11
func NewUserRepository(conf UserRepositoryConfig) (*UserRepository, error)
NewUserRepository creates a new UserRepository.
func (*UserRepository) Close ¶ added in v0.0.11
func (r *UserRepository) Close() error
Close closes the repository, releasing any open resources.
func (*UserRepository) Delete ¶ added in v0.0.11
func (r *UserRepository) Delete(ctx context.Context, input *DeleteUserInput) error
Delete deletes the user with the specified ID.
func (*UserRepository) DriverName ¶ added in v0.0.11
func (r *UserRepository) DriverName() string
DriverName returns the name of the driver.
func (*UserRepository) Insert ¶ added in v0.0.11
func (r *UserRepository) Insert(ctx context.Context, input *InsertUserInput) error
Insert a new user into the database.
func (*UserRepository) PingContext ¶ added in v0.0.11
func (r *UserRepository) PingContext(ctx context.Context) error
PingContext verifies a connection to the repository is still alive, establishing a connection if necessary.
func (*UserRepository) Select ¶ added in v0.0.11
func (r *UserRepository) Select(ctx context.Context, input *SelectUsersInput) (*SelectUsersOutput, error)
func (*UserRepository) SelectUserByEmail ¶ added in v0.0.11
SelectUserByEmail returns the user with the specified email.
func (*UserRepository) SelectUserByID ¶ added in v0.0.11
SelectUserByID returns the user with the specified ID.
func (*UserRepository) Update ¶ added in v0.0.11
func (r *UserRepository) Update(ctx context.Context, input *UpdateUserInput) error
Update updates the user with the specified ID.