common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("record not found")
	ErrInvalidInput  = errors.New("invalid input")
	ErrDatabaseError = errors.New("database error")
)

Common store errors

Functions

func NewDatabaseError

func NewDatabaseError(op, entity, id string, err error) error

NewDatabaseError creates a new database error

func NewInvalidInputError

func NewInvalidInputError(op, entity, id string, err error) error

NewInvalidInputError creates a new invalid input error

func NewNotFoundError

func NewNotFoundError(op, entity, id string) error

NewNotFoundError creates a new not found error

Types

type PaginationParams

type PaginationParams struct {
	Page     int
	PageSize int
}

PaginationParams represents the parameters for pagination

func NewPaginationParams

func NewPaginationParams(page, pageSize int) PaginationParams

NewPaginationParams creates a new PaginationParams with default values

func (PaginationParams) GetLimit

func (p PaginationParams) GetLimit() int

GetLimit returns the page size as the limit

func (PaginationParams) GetOffset

func (p PaginationParams) GetOffset() int

GetOffset calculates the offset for the current page

type PaginationResult

type PaginationResult struct {
	Items      any // The items in the current page
	TotalItems int // Total number of items
	Page       int // Current page number
	PageSize   int // Number of items per page
	TotalPages int // Total number of pages
}

PaginationResult represents the result of a paginated query

func NewPaginationResult

func NewPaginationResult(items any, totalItems, page, pageSize int) PaginationResult

NewPaginationResult creates a new PaginationResult

type StoreError

type StoreError struct {
	Op      string // Operation that failed
	Entity  string // Entity type (e.g., "user", "form")
	ID      string // Entity ID
	Err     error  // The underlying error
	Details string // Additional error details
}

StoreError represents a store operation error

func (*StoreError) Error

func (e *StoreError) Error() string

Error implements the error interface

func (*StoreError) Unwrap

func (e *StoreError) Unwrap() error

Unwrap returns the underlying error

Jump to

Keyboard shortcuts

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