models

package
v0.0.0-...-1893941 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseAPIResponse

type BaseAPIResponse struct {
	Message string `json:"message"`
}

type BaseDBResponse

type BaseDBResponse struct {
	Success bool   `mapstructure:"success"`
	Message string `mapstructure:"message"`
}

type BaseModel

type BaseModel interface {
	Save() error
}

type BaseSchema

type BaseSchema interface {
	Map(io.ReadCloser) (BaseSchema, error)
	Validate() []error
	ToModel() (BaseModel, error)
}

type Record

type Record struct {
	ID            int64        `mapstructure:"record_id" json:"id"`
	ReferenceID   string       `mapstructure:"record_reference_id" json:"referenceId"`
	Type          RecordType   `mapstructure:"record_type" json:"type"`
	Notes         *string      `mapstructure:"record_notes" json:"notes,omitempty"`
	Geopoint      pgtype.Point `mapstructure:"record_geo_point" json:"-"`
	FloatGeopoint [2]float64   `mapstructure:"-" json:"geopoint"`
	Address       string       `mapstructure:"record_address" json:"address"`
	CreatedAt     time.Time    `mapstructure:"created_at" json:"createdAt"`
}

func (*Record) Save

func (r *Record) Save() error

Save

type RecordSchema

type RecordSchema struct {
	Type     RecordType `json:"recordType"`
	Notes    *string    `json:"notes"`
	Geopoint [2]float64 `json:"geopoint" validate:"empty=false & eq=2"`
	Address  string     `json:"address"`
}

func (RecordSchema) Map

func (rs RecordSchema) Map(body io.ReadCloser) (*RecordSchema, error)

Map

func (RecordSchema) ToModel

func (rs RecordSchema) ToModel() (*Record, error)

LoadModel

func (RecordSchema) Validate

func (rs RecordSchema) Validate() error

Validate

type RecordType

type RecordType string
const (
	RT_POOP   RecordType = "poop"
	RT_ANIMAL RecordType = "dead_animal"
)

func (RecordType) IsValid

func (rt RecordType) IsValid() bool

type SearchQuery

type SearchQuery struct {
	Page   int
	Amount int
}

func (SearchQuery) GetOffset

func (sq SearchQuery) GetOffset() int

func (SearchQuery) ParseParams

func (sq SearchQuery) ParseParams(query url.Values) (*SearchQuery, error)

ParseParams

Jump to

Keyboard shortcuts

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