model

package
v0.0.0-...-411c821 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package loc "verpackt" loc.Location für gorm. Dazu müssen alle Felder global sichtbar sein.

Index

Constants

This section is empty.

Variables

View Source
var SomePersons = []Person{
	{Name: "Captain Kirk"},
	{Name: "Lara Croft"},
}
View Source
var SomeTrips = []Trip{
	{Comment: "Karneval", Start: tx("11.11.2016")},
	{Comment: "Neujahrstrip", Start: tx("1.1.2017")},
	{Comment: "Sommerreise", Start: tx("12.7.2017")},
}

Functions

This section is empty.

Types

type City

type City struct {
	Model
	Location
	Name          string
	Inhabitants   int
	DestinationID uint
	Trips         []Trip `gorm:"many2many:trip_city;"`
}

model.City "verpackt" poi.City für gorm. model.City macht alle Felder global sichtbar, sonst kann gorm damit nicht arbeiten.

func New

func New(c poi.City) (city City)

Konstruktor Function

type Destination

type Destination struct {
	Model
	Dest City
}

type Location

type Location struct {
	Lat float64
	Lon float64
}

func (Location) Dist

func (l Location) Dist(lctr loc.Locator) float64

Berechne Abstand zwischen zwei Loc's, implementiert Interface Distancer.

func (Location) LatLon

func (loc Location) LatLon() (lat, lon float64)

Implementiere Interface Locator

type Model

type Model struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Person

type Person struct {
	Model
	Name  string
	Trips []Trip
}

type Trip

type Trip struct {
	Model
	Comment  string
	Start    time.Time
	PersonID uint
	Cities   []City `gorm:"many2many:trip_city;"`
}

Jump to

Keyboard shortcuts

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