model

package
v0.0.0-...-4e1abb7 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

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

func StructToMap

func StructToMap(obj interface{}, m map[string]string) map[string]string

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

func (base *Base) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

func (*Base) BeforeUpdate

func (base *Base) BeforeUpdate(scope *gorm.Scope) error

func (*Base) IsNew

func (base *Base) IsNew() bool

func (*Base) ToMap

func (base *Base) ToMap() map[string]string

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 GeoPoint

type GeoPoint struct {
	Lng float64 `json:"lng" conv:"dto"`
	Lat float64 `json:"lat" conv:"dto"`
}

func (*GeoPoint) Scan

func (p *GeoPoint) Scan(val interface{}) error

func (*GeoPoint) String

func (p *GeoPoint) String() string

func (GeoPoint) ToDTO

func (obj GeoPoint) ToDTO() (to dto.GeoPoint)

func (GeoPoint) Value

func (p GeoPoint) Value() (driver.Value, error)

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

Jump to

Keyboard shortcuts

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