models

package
v0.0.0-...-9de49aa Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2017 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogIndexPrefix ElasticSearch index name prefix
	LogIndexPrefix = "logs"
)

Variables

View Source
var (
	ErrorProjectNotFound = errors.New("Project not found")
)
View Source
var (
	ErrorUserNotFound = errors.New("User not found")
)

Functions

func DeleteProject

func DeleteProject(p *Project) *gorm.DB

func EmailExists

func EmailExists(email string) (bool, *gorm.DB)

func GetConnection

func GetConnection() *gorm.DB

GetConnection returns database connection instance

func HashPlainPassword

func HashPlainPassword(password string) string

func InitDatabase

func InitDatabase()

func NewConnection

func NewConnection() *gorm.DB

NewConnection creates new database connection

func ProjectIndexName

func ProjectIndexName(projectUUID string) string

ProjectIndexName build ElasticSearch index name for project logs.

Types

type BaseModel

type BaseModel struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"` // TODO: Remove deleted_at. Records should be deleted permanently.
}

type Project

type Project struct {
	BaseModel
	Name    string `json:"name"`
	UUID    string `json:"uuid"`
	OwnerID uint   `json:"owner_id"`
}

func CreateProject

func CreateProject(name string, u *User) (*Project, *gorm.DB)

func FindAllProjectsByUser

func FindAllProjectsByUser(u *User) ([]Project, *gorm.DB)

func FindProjectById

func FindProjectById(id interface{}, u *User) (*Project, *gorm.DB)

func FindProjectByUUID

func FindProjectByUUID(uuid string) (*Project, *gorm.DB)

func SaveProject

func SaveProject(p *Project) (*Project, *gorm.DB)

func (*Project) IndexName

func (p *Project) IndexName() string

IndexName build ElasticSearch index name for project logs.

type User

type User struct {
	BaseModel
	Email    string
	Name     string
	Password string
}

func CreateUser

func CreateUser(email, name, password string) (*User, *gorm.DB)

func FindUserByEmail

func FindUserByEmail(email string) (*User, *gorm.DB)

func FindUserByID

func FindUserByID(id interface{}) (*User, *gorm.DB)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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