data

package module
v0.0.0-...-e34e6ff Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 6 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB)

Types

type Account

type Account struct {
	gorm.Model
	Name     string
	UUID     string `gorm:"type:varchar(100);primaryKey;"`
	Users    []User
	Projects []Project
}

func (*Account) BeforeCreate

func (a *Account) BeforeCreate(tx *gorm.DB) error

type GormTCPConnectionConfig

type GormTCPConnectionConfig struct {
	// dsn := "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
	UserName string
	Password string
	DBName   string
	Host     string
	Charset  string
	Port     string
}

func (*GormTCPConnectionConfig) OpenMySql

func (c *GormTCPConnectionConfig) OpenMySql() (*gorm.DB, error)

type HitEvent

type HitEvent struct {
	gorm.Model
	Body       string `gorm:"type:text"`
	Query      string `gorm:"type:varchar(200)"`
	FromIp     string `gorm:"type:varchar(15)"`
	UserAgent  string `gorm:"type:varchar(200)"`
	HttpMethod string `gorm:"type:varchar(10)"`
	AccountID  uint   `gorm:"not null;"`
	Account    Account
}

type HitPoint

type HitPoint struct {
	gorm.Model
	UUID        string `gorm:"type:varchar(100);primaryKey;<-:create"`
	Name        string `gorm:"not null"` // add composite constraint
	Description string `gorm:"type:text"`
	ProjectID   uint
	Project     Project
	AccountID   uint `gorm:"not null;"`
	Account     Account
}

func (*HitPoint) BeforeCreate

func (h *HitPoint) BeforeCreate(db *gorm.DB) error

func (*HitPoint) Create

func (h *HitPoint) Create(db *gorm.DB) error

type Plan

type Plan struct {
	gorm.Model
	Name         string `gorm:"not null;"`
	UUID         string `gorm:"type:varchar(100);primaryKey;"`
	DurationType PlanDuration
}

func (*Plan) BeforeCreate

func (p *Plan) BeforeCreate(tx *gorm.DB) error

type PlanDuration

type PlanDuration uint8
const (
	Lifetime PlanDuration = 1
	Monthly  PlanDuration = 2
)

type Project

type Project struct {
	gorm.Model
	Name      string `gorm:"not null;unique;"`
	UUID      string `gorm:"type:varchar(100);primaryKey;"`
	AccountID uint   `gorm:"not null;"`
	Account   Account
}

func (*Project) BeforeCreate

func (proj *Project) BeforeCreate(tx *gorm.DB) error

func (*Project) CreateProject

func (p *Project) CreateProject(user User, db *gorm.DB) error

type ProjectUser

type ProjectUser struct {
	ProjectId uint `gorm:"not null;"`
	UserId    uint `gorm:"not null;"`
	AccountID uint
	Account   Account
}

type Subscription

type Subscription struct {
	gorm.Model
	UUID      string `gorm:"type:varchar(100);primaryKey;"`
	PlanID    uint   `gorm:"not null;"`
	Plan      Plan
	AccountID uint `gorm:"not null;"`
	Account   Account
}

func (*Subscription) BeforeCreate

func (s *Subscription) BeforeCreate(tx *gorm.DB) error

type User

type User struct {
	gorm.Model
	UUID         string `gorm:"type:varchar(100);primaryKey;"`
	Name         string `gorm:"type:varchar(255);not null"`
	Email        string `gorm:"type:varchar(500);not null;unique"`
	PasswordHash string `gorm:"type:varchar(255);not null"`
	IsVerified   bool   `gorm:"not null;"`
	AccountID    uint   `gorm:"not null;"`
	Account      Account
}

func AuthenticateUserByEmailPassword

func AuthenticateUserByEmailPassword(db *gorm.DB, email string, password string) (*User, error)

func UserByEmail

func UserByEmail(db *gorm.DB, email string) (*User, error)

func UserById

func UserById(db *gorm.DB, id int) (*User, error)

func (*User) Create

func (user *User) Create(db *gorm.DB, password string) error

func (*User) SetPassword

func (user *User) SetPassword(password string) (err error)

func (*User) VerifyPasswordMatch

func (user *User) VerifyPasswordMatch(password string) error

Jump to

Keyboard shortcuts

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