model

package
v0.0.0-...-a1560d6 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoinsCreatedThisWeekForUser

func CoinsCreatedThisWeekForUser(user *User) int64

func CreateCoin

func CreateCoin(coin *Coin) (err error)

func CreateNft

func CreateNft(nft *Nft) (err error)

func CreateTransaction

func CreateTransaction(transaction *Transaction) (err error)

func CreateUser

func CreateUser(user *User) (err error)

Types

type Coin

type Coin struct {
	gorm.Model
	Hash            uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4()"`
	Origin          string
	MinedByUserID   uint
	UserID          uint
	CreatedByUserId uint
}

func (*Coin) DestroyCoin

func (c *Coin) DestroyCoin() (err error)

type Nft

type Nft struct {
	gorm.Model
	Hash            uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4()"`
	OwnedByUserId   uint
	CreatedByUserId uint
	MinBid          uint
	PricePaid       uint
	Name            string `gorm:"unique"`
	SourceURL       string
	DisplayURL      string
}

func (*Nft) DestroyNft

func (n *Nft) DestroyNft() (err error)

type Transaction

type Transaction struct {
	gorm.Model
	Amount     int
	Memo       string
	FromUserID uint
	ToUserID   uint
}

type User

type User struct {
	gorm.Model
	Email     string
	FirstName string
	LastName  string
	SlackID   string

	Coins        []Coin
	CoinsCreated []Coin `gorm:"foreignKey:CreatedByUserId"`

	TransactionsTo   []Transaction `gorm:"foreignKey:ToUserID"`
	TransactionsFrom []Transaction `gorm:"foreignKey:FromUserID"`
}

func GetOrCreateUserBySlackID

func GetOrCreateUserBySlackID(slackId string) (*User, error)

func GetUserByID

func GetUserByID(id int64) (*User, bool, error)

func GetUserBySlackID

func GetUserBySlackID(id string) (*User, bool, error)

func (*User) GetBalance

func (u *User) GetBalance() int64

func (*User) GetCoin

func (u *User) GetCoin() (*Coin, error)

func (*User) GetNfts

func (u *User) GetNfts() ([]Nft, error)

func (*User) Role

func (u *User) Role() *UserRole

type UserRole

type UserRole struct {
	Admin bool
	Lord  bool
}

Jump to

Keyboard shortcuts

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