database

package
v0.0.0-...-418229d Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoeffPair

type CoeffPair struct {
	Credit float64 `json:"credit"`
	Debt   float64 `json:"debt"`
}

type DBHandler

type DBHandler struct {
	DB *gorm.DB
}

func NewDB

func NewDB(filePath string) (*DBHandler, error)

type Dong

type Dong struct {
	gorm.Model
	ID           uint
	Name         string
	Desc         string
	Transactions []Transaction
}

type DongUser

type DongUser struct {
	gorm.Model
	ID           uint
	UserID       uint `gorm:"UNIQUE_INDEX:compositeindex"`
	DongID       uint `gorm:"UNIQUE_INDEX:compositeindex"`
	IsDongAdmin  bool
	Transactions []Transaction
}

type ShareCoeffs

type ShareCoeffs map[uint]CoeffPair

func (*ShareCoeffs) GetCoeffSum

func (sc *ShareCoeffs) GetCoeffSum() (credit, debt float64)

func (*ShareCoeffs) Scan

func (sc *ShareCoeffs) Scan(value interface{}) error

func (ShareCoeffs) Value

func (sc ShareCoeffs) Value() (driver.Value, error)

type Transaction

type Transaction struct {
	gorm.Model
	ID          uint
	DongUserID  uint
	DongID      uint
	Expense     int
	ShareCoeffs ShareCoeffs `gorm:"type:text"`
	Desc        string
}

type User

type User struct {
	gorm.Model
	ID        uint
	Name      string
	IsAdmin   bool
	DongUsers []DongUser
}

Jump to

Keyboard shortcuts

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