Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashPassword ¶
HashPassword hashes a plaintext password using bcrypt. It takes the plaintext password as input and returns the hashed password and any error that occurs during hashing.
Types ¶
type FilterModel ¶
type FilterModel struct { Field string `query:"field" json:"field"` Value string `query:"value" json:"value"` Comparison string `query:"comparison" json:"comparison"` }
FilterModel defines the structure for filtering query results.
type ListQuery ¶
type ListQuery struct { Size int `query:"size" json:"size,omitempty"` Page int `query:"page" json:"page,omitempty"` OrderBy string `query:"orderBy" json:"orderBy,omitempty"` Filters []*FilterModel `query:"filters" json:"filters,omitempty"` }
ListQuery represents the parameters for querying a paginated list.
func (*ListQuery) GetLimit ¶
GetLimit returns the maximum number of items to retrieve, based on the page size.
func (*ListQuery) GetOffset ¶
GetOffset calculates the offset for the database query based on the current page and page size.
func (*ListQuery) GetOrderBy ¶
GetOrderBy returns the field by which the results should be ordered.
type ListResult ¶
type ListResult[T interface{}] struct { Size int `json:"size,omitempty" bson:"size"` Page int `json:"page,omitempty" bson:"page"` TotalItems int64 `json:"totalItems,omitempty" bson:"totalItems"` TotalPage int `json:"totalPage,omitempty" bson:"totalPage"` Items []T `json:"items,omitempty" bson:"items"` }
ListResult encapsulates the result of a paginated query.
func NewListResult ¶
func NewListResult[T any](items []T, size int, page int, totalItems int64) *ListResult[T]
NewListResult constructs a new ListResult instance.