datatypes

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModelFieldTypeElmIfValid added in v0.1.45

func GetModelFieldTypeElmIfValid(modelObj interface{}, fieldName string) (reflect.Type, error)

GetModelFieldTypeElmIfValid is like GetModelFieldTypeIfValid, but get the element if it is array

func GetModelFieldTypeIfValid added in v0.1.45

func GetModelFieldTypeIfValid(modelObj interface{}, fieldName string) (reflect.Type, error)

GetModelFieldTypeIfValid make sure the fieldName is in the modelObj, and find the correct reflect.Type func GetModelFieldTypeIfValid(modelObj models.IModel, fieldName string) (reflect.Type, error) { If this is an array, get the actual type instead of the array type

func TransformFieldValue added in v0.1.45

func TransformFieldValue(typeInString string, fieldValue string) (interface{}, error)

TransformFieldValue transforms type in URL parameter to the proper data types

func TransformFieldValues added in v0.4.14

func TransformFieldValues(typeInString string, fieldValues []string) ([]interface{}, error)

TransformFieldValues transforms type in URL parameters to the proper data types

Types

type EWKBPoint

type EWKBPoint struct {
	Point wkb.Point
}

EWKBPoint encapsulate Point and handles value and scanners to work with Gorm Fetch by .Point.X(), .Point.Y()

func NewEWKBPoint added in v0.1.50

func NewEWKBPoint(coords []float64) *EWKBPoint

NewEWKBPoint creates a new EWKBPoint

func (*EWKBPoint) MarshalJSON

func (m *EWKBPoint) MarshalJSON() ([]byte, error)

MarshalJSON customizes unmarshalling from JSON array (e.g. [10, 20])

func (*EWKBPoint) Scan

func (m *EWKBPoint) Scan(src interface{}) error

Scan satisfies the Scanner interace and is responsible for reading data from the database

func (*EWKBPoint) UnmarshalJSON

func (m *EWKBPoint) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON json satisfies the JSON library

{
    "type": "Point",
    "coordinates": [30, 10]
}

func (*EWKBPoint) Value

func (m *EWKBPoint) Value() (driver.Value, error)

Value satisfies the Valuer interace and is responsible for writing data to the database

type EWKBPolygon

type EWKBPolygon struct {
	Polygon ewkb.Polygon
}

EWKBPolygon encapsulate Polygon and handles value and scanners to work with Gorm

func (*EWKBPolygon) MarshalJSON

func (m *EWKBPolygon) MarshalJSON() ([]byte, error)

MarshalJSON customizes unmarshalling from JSON array (e.g. [10, 20])

func (*EWKBPolygon) Scan

func (m *EWKBPolygon) Scan(src interface{}) error

Scan satisfies the Scanner interace and is responsible for reading data from the database

func (*EWKBPolygon) UnmarshalJSON

func (m *EWKBPolygon) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON json satisfies the JSON library https://en.wikipedia.org/wiki/GeoJSON

{
    "type": "Polygon",
    "coordinates": [
        [[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]
    ]
}

func (*EWKBPolygon) Value

func (m *EWKBPolygon) Value() (driver.Value, error)

Value satisfies the Valuer interace and is responsible for writing data to the database

type FilterFunc added in v0.1.8

type FilterFunc func(v string) bool

type SetString added in v0.1.8

type SetString struct {
	List map[string]struct{} //empty structs occupy 0 memory
}

func NewSetString added in v0.1.8

func NewSetString() *SetString

func (*SetString) Add added in v0.1.8

func (s *SetString) Add(v string)

func (*SetString) AddMulti added in v0.1.8

func (s *SetString) AddMulti(List ...string)

AddMulti Add multiple values in the set

func (*SetString) Clear added in v0.1.8

func (s *SetString) Clear()

func (*SetString) Difference added in v0.1.8

func (s *SetString) Difference(s2 *SetString) *SetString

Difference returns the subset from s, that doesn't exists in s2 (param)

func (*SetString) Filter added in v0.1.8

func (s *SetString) Filter(P FilterFunc) *SetString

Filter returns a subset, that contains only the values that satisfies the given predicate P

func (*SetString) Has added in v0.1.8

func (s *SetString) Has(v string) bool

func (*SetString) Intersect added in v0.1.8

func (s *SetString) Intersect(s2 *SetString) *SetString

func (*SetString) Remove added in v0.1.8

func (s *SetString) Remove(v string)

func (*SetString) Size added in v0.1.8

func (s *SetString) Size() int

func (*SetString) Union added in v0.1.8

func (s *SetString) Union(s2 *SetString) *SetString

type TimeM

type TimeM struct {
	Time time.Time
}

TimeM (Time convertable from JSON int representing minisecond) encapsulate unix time, converts to and from JSON to Unix time in millisecond

func (*TimeM) MarshalJSON

func (t *TimeM) MarshalJSON() ([]byte, error)

MarshalJSON customizes unmarshalling from JSON array

func (*TimeM) UnmarshalJSON

func (t *TimeM) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshalls it from a string of millisecond

type UUID

type UUID struct {
	UUID uuid.UUID
}

UUID string

func NewUUID

func NewUUID() *UUID

NewUUID generates a UUID that's partly V1 and partly V4 Like V4, but use timestamp as part of V1 to increase locality (performance)

func NewUUIDFromString

func NewUUIDFromString(s string) (u *UUID, err error)

NewUUIDFromString creates UUID from string

func (*UUID) MarshalJSON

func (u *UUID) MarshalJSON() ([]byte, error)

MarshalJSON customizes unmarshalling from JSON array

func (*UUID) Scan

func (u *UUID) Scan(src interface{}) error

Scan satisfies the Scanner interace and is responsible for reading data from the database

func (*UUID) String

func (u *UUID) String() string

Value satisfies the Valuer interace and is responsible for writing data to the database

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshalls it from a string of millisecond

func (*UUID) Value

func (u *UUID) Value() (driver.Value, error)

Value satisfies the Valuer interace and is responsible for writing data to the database

Jump to

Keyboard shortcuts

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