model

package
v0.0.0-...-0571e71 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedDataType = errors.New("unsupported data type")

Functions

func IsLocation

func IsLocation(value reflect.Value) bool

func IsRegion

func IsRegion(value reflect.Value) bool

func IsTimestamp

func IsTimestamp(value reflect.Value) bool

func ParseObject

func ParseObject(target interface{}, schema Schema) ([]map[string]interface{}, error)

func ParseSingleObject

func ParseSingleObject(target interface{}, schema Schema) (map[string]interface{}, error)

func ParseType

func ParseType(target interface{}) (string, error)

Types

type DataType

type DataType string
const (
	Bool          DataType = "bool"
	Int           DataType = "int"
	Uint          DataType = "uint"
	Float         DataType = "float"
	String        DataType = "string"
	Time          DataType = "time"
	Bytes         DataType = "bytes"
	LocationType  DataType = "location"
	RegionType    DataType = "region"
	TimestampType DataType = "timestamp"
)

type Field

type Field struct {
	Name              string
	DBName            string
	FieldType         reflect.Type
	IndirectFieldType reflect.Type
	DataType          DataType
	StructField       reflect.StructField
	Tag               reflect.StructTag
	TagSettings       map[string]string
	PrimaryKey        bool
	AutoIncrement     bool
	NotNull           bool
	Unique            bool
	HasDefaultValue   bool
	DefaultValue      interface{}
	Schema            *Schema
}

func (Field) GetFullDBName

func (field Field) GetFullDBName() string

func (Field) GetFullName

func (field Field) GetFullName() string

type Location

type Location struct {
	// contains filtered or unexported fields
}

func NewLocation

func NewLocation(lon float64, lat float64) Location

func (*Location) IsEqual

func (l *Location) IsEqual(other Location) bool

func (Location) IsLocation

func (l Location) IsLocation() bool

func (Location) IsRegion

func (l Location) IsRegion() bool

func (*Location) Lat

func (l *Location) Lat() float64

func (*Location) Lon

func (l *Location) Lon() float64

func (*Location) Scan

func (l *Location) Scan(value interface{}) error

func (Location) String

func (l Location) String() string

func (Location) Value

func (l Location) Value() (driver.Value, error)

type Region

type Region struct {
	// contains filtered or unexported fields
}

func NewRectRegion

func NewRectRegion(minLon float64, maxLon float64, minLat float64, maxLat float64) Region

Convenience functions for Region construction

func NewRegion

func NewRegion(coords [][]float64) Region

func (*Region) Coords

func (r *Region) Coords() [][]float64

func (*Region) IsEqual

func (r *Region) IsEqual(other Region) bool

func (Region) IsLocation

func (r Region) IsLocation() bool

func (Region) IsRegion

func (r Region) IsRegion() bool

func (*Region) Scan

func (r *Region) Scan(value interface{}) error

func (Region) String

func (r Region) String() string

func (Region) Value

func (r Region) Value() (driver.Value, error)

type Schema

type Schema struct {
	Name           string
	ModelType      reflect.Type
	Table          string
	DBNames        []string
	PrimaryFields  []*Field
	Fields         []*Field
	FieldsByName   map[string]*Field
	FieldsByDBName map[string]*Field

	AllFieldNames      *utils.Set
	PrimaryFieldNames  *utils.Set // Used for convenience
	LocationFieldNames *utils.Set
	RegionFieldNames   *utils.Set
}

func Parse

func Parse(target interface{}) (*Schema, error)

func (*Schema) ParseField

func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field

func (Schema) SetDefaultValues

func (schema Schema) SetDefaultValues(target interface{}) error

type SpatialObject

type SpatialObject interface {
	IsLocation() bool
	IsRegion() bool
}

type Timestamp

type Timestamp struct {
	// contains filtered or unexported fields
}

func NewTimestamp

func NewTimestamp(timestamp time.Time) Timestamp

func (*Timestamp) Scan

func (t *Timestamp) Scan(value interface{}) error

func (Timestamp) Value

func (t Timestamp) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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