db

package
v0.0.0-...-0ca9a5c Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: GPL-3.0 Imports: 17 Imported by: 1

Documentation

Overview

Based on: http://www.booneputney.com/development/gorm-golang-jsonb-value-copy/ Therefore credit is due to Boone Putney. Thank you!

Very heavily inspired by https://github.com/nferruzzi/gormGIS Therefore credit is due to nferruzzi. Thank you!

Index

Constants

View Source
const (
	NotificationMatching string = "matching"
)

Variables

This section is empty.

Functions

func AddDefaultData

func AddDefaultData(db *gorm.DB)

Insert default data into Permissions, Groups and Tags table

func InitDB

func InitDB() *gorm.DB

Create connection to our database from environment file.

func NotificationReaper

func NotificationReaper(db *gorm.DB, expiryOffset time.Duration, sleepOffset time.Duration)

For notifications.

func OfferRequestReaper

func OfferRequestReaper(db *gorm.DB, table string, sleepOffset time.Duration)

For offers and requests.

Types

type GeoPolygon

type GeoPolygon struct {
	Points []gormGIS.GeoPoint
}

func (*GeoPolygon) Scan

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

func (GeoPolygon) Value

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

type Group

type Group struct {
	ID           string `gorm:"primary_key"`
	DefaultGroup bool   `gorm:"not null"`
	RegionId     string `gorm:"index;not null"`
	Region       Region `gorm:"ForeignKey:RegionId;AssociationForeignKey:Refer"`
	Users        []User `gorm:"many2many:user_groups"`
	AccessRight  string
	Description  string
}

type Matching

type Matching struct {
	ID        string  `gorm:"primary_key"`
	RegionId  string  `gorm:"index;not null"`
	Region    Region  `gorm:"ForeignKey:RegionId;AssociationForeignKey:Refer"`
	OfferId   string  `gorm:"index;not null"`
	Offer     Offer   `gorm:"ForeignKey:OfferId;AssociationForeignKey:Refer"`
	RequestId string  `gorm:"index;not null"`
	Request   Request `gorm:"ForeignKey:RequestId;AssociationForeignKey:Refer"`
	Invalid   bool    `gorm:"not null"`
}

type MatchingScore

type MatchingScore struct {
	RegionID      string  `gorm:"primary_key"`
	Region        Region  `gorm:"ForeignKey:RegionID;AssociationForeignKey:Refer"`
	OfferID       string  `gorm:"primary_key"`
	Offer         Offer   `gorm:"ForeignKey:OfferID;AssociationForeignKey:Refer"`
	RequestID     string  `gorm:"primary_key"`
	Request       Request `gorm:"ForeignKey:RequestID;AssociationForeignKey:Refer"`
	MatchingScore float64 `gorm:"not null"`
	Recommended   bool
}

type Notification

type Notification struct {
	ID        string    `gorm:"primary_key"`
	Type      string    `gorm:"index;not null"`
	UserID    string    `gorm:"not null"`
	ItemID    string    `gorm:"not null"`
	Read      bool      `gorm:"not null"`
	CreatedAt time.Time `gorm:"not null"`
}

type Offer

type Offer struct {
	ID             string           `gorm:"primary_key"`
	Name           string           `gorm:"index;not null"`
	UserID         string           `gorm:"index;not null"`
	User           User             `gorm:"ForeignKey:UserID;AssociationForeignKey:Refer"`
	Location       gormGIS.GeoPoint `gorm:"not null" sql:"type:geometry(Geometry,4326)"`
	Radius         float64          `gorm:"not null"`
	Tags           []Tag            `gorm:"many2many:offer_tags"`
	Description    string
	Regions        []Region  `gorm:"many2many:region_offers"`
	ValidityPeriod time.Time `gorm:"not null"`
	Matched        bool      `gorm:"not null"`
	Expired        bool      `gorm:"not null"`
}

type OffersByUUID

type OffersByUUID []Offer

Make offers list sortable.

func (OffersByUUID) Len

func (o OffersByUUID) Len() int

func (OffersByUUID) Less

func (o OffersByUUID) Less(i, j int) bool

func (OffersByUUID) Swap

func (o OffersByUUID) Swap(i, j int)

type PhoneNumbers

type PhoneNumbers []string

func (*PhoneNumbers) Scan

func (num *PhoneNumbers) Scan(value interface{}) error

func (PhoneNumbers) Value

func (num PhoneNumbers) Value() (driver.Value, error)

type Region

type Region struct {
	ID                    string     `gorm:"primary_key"`
	Name                  string     `gorm:"not null"`
	Boundaries            GeoPolygon `gorm:"not null" sql:"type:geometry(Geometry,4326)"`
	Description           string     `gorm:"not null"`
	Matchings             []Matching
	Offers                []Offer   `gorm:"many2many:region_offers"`
	Requests              []Request `gorm:"many2many:region_requests"`
	RecommendationUpdated bool
}

type Request

type Request struct {
	ID             string           `gorm:"primary_key"`
	Name           string           `gorm:"index;not null"`
	UserID         string           `gorm:"index;not null"`
	User           User             `gorm:"ForeignKey:UserID;AssociationForeignKey:Refer"`
	Location       gormGIS.GeoPoint `gorm:"not null" sql:"type:geometry(Geometry,4326)"`
	Radius         float64          `gorm:"not null"`
	Tags           []Tag            `gorm:"many2many:request_tags"`
	Description    string
	Regions        []Region  `gorm:"many2many:region_requests"`
	ValidityPeriod time.Time `gorm:"not null"`
	Matched        bool      `gorm:"not null"`
	Expired        bool      `gorm:"not null"`
}

type RequestsByUUID

type RequestsByUUID []Request

Make requests list sortable.

func (RequestsByUUID) Len

func (r RequestsByUUID) Len() int

func (RequestsByUUID) Less

func (r RequestsByUUID) Less(i, j int) bool

func (RequestsByUUID) Swap

func (r RequestsByUUID) Swap(i, j int)

type Tag

type Tag struct {
	Name string `gorm:"primary_key"`
}

type TagsByName

type TagsByName []Tag

Make tags list sortable.

func (TagsByName) Len

func (t TagsByName) Len() int

func (TagsByName) Less

func (t TagsByName) Less(i, j int) bool

func (TagsByName) Swap

func (t TagsByName) Swap(i, j int)

type User

type User struct {
	ID            string       `gorm:"primary_key"`
	Name          string       `gorm:"not null"`
	PreferredName string       `gorm:"not null"`
	Mail          string       `gorm:"index;not null;unique"`
	MailVerified  bool         `gorm:"not null"`
	PhoneNumbers  PhoneNumbers `gorm:"not null" sql:"type:jsonb"`
	PasswordHash  string       `gorm:"not null;unique"`
	Groups        []Group      `gorm:"many2many:user_groups"`
	Enabled       bool         `gorm:"not null"`
}

Jump to

Keyboard shortcuts

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