database

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 6 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(conf *Config) (*gorm.DB, error)

Types

type BaseModel

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

BaseModel declares base fields that are to be used on all models

type Config

type Config struct {
	Hostname string
	Port     int `default:"3306"`
	Username string
	Password string
	Database string
	ShowLogs bool `split_words:"true" default:"false"`
}

type Team

type Team struct {
	BaseModel
	Name  string `gorm:"size:128;not null;unique_index;"`
	Email string `gorm:"size:64;"`
	URL   string `gorm:"size:1024;"`
	Users []User `gorm:"many2many:teams_users;"`
}

Team represents a team of developers

type User

type User struct {
	BaseModel
	Name     string `gorm:"size:128;not null;unique_index;"`
	Email    string `gorm:"size:64;not null;unique_index;"`
	Password string `gorm:"size:60;not null;"`
	IsAdmin  bool   `gorm:"not null;"`
	Teams    []Team `gorm:"many2many:teams_users;"`
}

User represents a developer

Jump to

Keyboard shortcuts

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