Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultPaginationPage = 1 DefaultPaginationPerPage = 10 DefaultOrderField = "created_at" DefaultOrderDirection = "asc" EmptyUUID = "00000000-0000-0000-0000-000000000000" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
type Base struct {
//ID value example: 86793486-725e-46e9-bbd7-6dac2a6445ee => 8 + 6 + 5 + 5 + 12
//ID uuid.UUID `gorm:"type:varchar(36);primary_key;not null"` //sqlite doesn't support uuid
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key;not null" conv:"dto"` // postgres supports uuid
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP;not null"`
UpdatedAt time.Time `conv:"dto"`
DeletedAt *time.Time `sql:"index" conv:"dto"`
}
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; should be called at postgres db first Base contains common columns
func (*Base) BeforeCreate ¶
BeforeCreate will set a UUID rather than numeric ID.
type CommonSearchParams ¶
type CommonSearchParams struct {
SearchParams url.Values
Page *int
PerPage *int
SortField *string
SortDirection *string
}
func CommonSearchParamsFromContext ¶
func CommonSearchParamsFromContext(c echo.Context) *CommonSearchParams
type Pagination ¶
type Pagination struct {
Page int `conv:"pagination"`
PerPage int `conv:"pagination"`
SortField string `conv:"pagination"`
SortDirection string `conv:"pagination"`
Total int `conv:"pagination"`
}
func PagingFromSearchParams ¶
func PagingFromSearchParams(params *CommonSearchParams) Pagination
Click to show internal directories.
Click to hide internal directories.