Documentation ¶
Index ¶
- type Address
- type Database
- type Gorm
- func (g Gorm) Close() error
- func (g Gorm) CreateOrUpdateAddress(user *User, address Address) error
- func (g Gorm) CreateTables(recreate bool) error
- func (g Gorm) CreateUser(user *User) error
- func (g Gorm) DeleteAddress(address Address) error
- func (g Gorm) DeleteUser(user User) error
- func (g Gorm) GetAddress(id uint) (Address, error)
- func (g Gorm) GetAddressByAddressType(user User, addressType int) (Address, error)
- func (g Gorm) GetAddresses(user User) ([]Address, error)
- func (g Gorm) GetUser(id uint) (User, error)
- func (g Gorm) GetUserByDomainUsername(domain, username string) (User, error)
- func (g Gorm) HasTables() bool
- func (g Gorm) UpdateUser(user User) error
- type Model
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { Model UserID uint `gorm:"not null;unique_index:idx_userid_type"` Address string `gorm:"not null" json:"address"` AddressType int `gorm:"not null;unique_index:idx_userid_type" json:"address_type"` }
Address represents a crypto address and it's address type
type Database ¶
type Database interface { Close() error CreateTables(bool) error HasTables() bool CreateUser(*User) error UpdateUser(User) error CreateOrUpdateAddress(*User, Address) error DeleteUser(user User) error DeleteAddress(address Address) error GetUser(id uint) (User, error) GetUserByDomainUsername(domain, username string) (User, error) GetAddress(id uint) (Address, error) GetAddressByAddressType(user User, addressType int) (Address, error) GetAddresses(user User) ([]Address, error) }
Database represents the functionality that any peristance layer for this server must satisfy
type Gorm ¶
type Gorm struct {
// contains filtered or unexported fields
}
Gorm represents a connection to GORM
func GetGormConnection ¶
GetGormConnection connects to the gorm database
func (Gorm) CreateOrUpdateAddress ¶
CreateOrUpdateAddress creates an address if it doesn't exist If it does already exist it is updated
func (Gorm) CreateTables ¶
CreateTables creates the necessary tables
func (Gorm) CreateUser ¶
CreateUser creates a user in the database
func (Gorm) DeleteAddress ¶
DeleteAddress deletes an address
func (Gorm) GetAddress ¶
GetAddress returns an address given the proper id
func (Gorm) GetAddressByAddressType ¶
GetAddressByAddressType returns an address given the proper id
func (Gorm) GetAddresses ¶
GetAddresses gets all not-deleted addresses associated with a user (user id must be provided)
func (Gorm) GetUserByDomainUsername ¶
GetUserByDomainUsername returns a user given the proper username
func (Gorm) UpdateUser ¶
UpdateUser updates user fields Does not update associated addresses
type User ¶
type User struct { Model Username string `gorm:"type:varchar(30);unique_index:idx_domain_username;not null" json:"username"` Password string `gorm:"not null" json:"password"` Domain string `gorm:"not null;unique_index:idx_domain_username" json:"domain"` Addresses []Address `json:"addresses"` }
User of the api