db

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

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

Go to latest
Published: Nov 18, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(migrate bool) (*gorm.DB, error)

Types

type AccessKey

type AccessKey struct {
	BaseModelSoftDelete
	OrganizationID uuid.UUID
	Name           string `gorm:"type:varchar(255)"`
	Token          []byte `gorm:"type:binary(60)"`
	ExpireAt       time.Time
}

type Asset

type Asset struct {
	BaseModelSoftDelete
	OrganizationID uuid.UUID
	AccessKeyID    uuid.UUID
	Name           string `gorm:"type:varchar(255)"`
	Description    string
	Type           string `gorm:"type:varchar(255)"`
	EventCaps      []EventCapability
	ImageURL       string
	Disabled       bool
}

type BaseModel

type BaseModel struct {
	// ID should use uuid_generate_v4() for the pk's
	ID        uuid.UUID  `gorm:"primary_key;type:uuid"`
	CreatedAt time.Time  `gorm:"index;not null"` // (My|Postgre)SQL
	UpdatedAt *time.Time `gorm:"index"`
}

BaseModel defines the common columns that all db structs should hold, usually db structs based on this have no soft delete

func (*BaseModel) BeforeCreate

func (base *BaseModel) BeforeCreate(scope *gorm.DB) error

BeforeCreate will set a UUID rather than numeric ID.

type BaseModelSoftDelete

type BaseModelSoftDelete struct {
	BaseModel
	DeletedAt *time.Time `sql:"index"`
}

BaseModelSoftDelete defines the common columns that all db structs should hold, usually. This struct also defines the fields for GORM triggers to detect the entity should soft delete

type DBType

type DBType = *gorm.DB

type EventCapability

type EventCapability struct {
	BaseModelSoftDelete
	AssetID     uuid.UUID
	Code        int64
	Name        string `gorm:"type:varchar(255)"`
	Description string
}

type Member

type Member struct {
	BaseModelSoftDelete
	OrganizationID uuid.UUID
	User           User
	UserID         uuid.UUID
	Disabled       bool
	Roles          string
}

type Organization

type Organization struct {
	BaseModelSoftDelete
	Name        string `gorm:"type:varchar(255)"`
	Description string
	Type        string `gorm:"type:varchar(255)"`
	Wallets     []Wallet
	Assets      []Asset
	Members     []Member
	Keys        []AccessKey
}

type Session

type Session struct {
	BaseModelSoftDelete
	Active  bool
	User    User
	Asset   Asset
	UserID  uuid.UUID
	AssetID uuid.UUID
}

type User

type User struct {
	BaseModelSoftDelete
	Name        string `gorm:"type:varchar(255)"`
	FirstName   string `gorm:"type:varchar(255)"`
	LastName    string `gorm:"type:varchar(255)"`
	NickName    string `gorm:"type:varchar(255)"`
	Email       string `gorm:"type:varchar(255)"`
	AvatarURL   string
	Description string
	UserID      string `sql:"index"`
	Members     []Member
	Wallet      *Wallet
	WalletID    *uuid.UUID

	LoginAt     *time.Time
	ConfirmedAt *time.Time
	VerifiedAt  *time.Time
	InvitedAt   *time.Time
}

type Wallet

type Wallet struct {
	BaseModelSoftDelete
	OrganizationID uuid.UUID
	UserID         uuid.UUID
	Organization   Organization
	EthAddress     string
}

Jump to

Keyboard shortcuts

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