Documentation
¶
Index ¶
- Constants
- Variables
- type Deed
- type DeedModel
- type DeedType
- type Guild
- type GuildModel
- func (m GuildModel) AnnouceChannel(g *Guild) string
- func (m GuildModel) DecryptEncSecret(g *Guild) ([]byte, error)
- func (m GuildModel) Delete(g *Guild) error
- func (m GuildModel) GetByGuildID(i string) (*Guild, error)
- func (m GuildModel) GetGuilds() ([]*Guild, error)
- func (m GuildModel) GetPrefBool(g *Guild, k GuildPrefKey) (bool, error)
- func (m GuildModel) GetPrefInt(g *Guild, k GuildPrefKey) (int, error)
- func (m GuildModel) GetPrefInt64(g *Guild, k GuildPrefKey) (int64, error)
- func (m GuildModel) GetPrefString(g *Guild, k GuildPrefKey) (string, error)
- func (m GuildModel) GetPrefStringEnc(g *Guild, k GuildPrefKey) (string, error)
- func (m GuildModel) Insert(g *Guild) error
- func (m GuildModel) PrefExists(g *Guild, k GuildPrefKey) (bool, error)
- func (m GuildModel) SetPref(g *Guild, k GuildPrefKey, v interface{}) error
- func (m GuildModel) SetPrefEnc(g *Guild, k GuildPrefKey, v interface{}) error
- type GuildPrefKey
- type Model
- type RewardType
- type TradeRoute
- type TradeRouteModel
- type User
- type UserModel
- func (m UserModel) DecryptEncSecret(u *User) ([]byte, error)
- func (m UserModel) Delete(u *User) error
- func (m UserModel) GetByUserID(i string) (*User, error)
- func (m UserModel) GetPrefBool(u *User, k UserPrefKey) (bool, error)
- func (m UserModel) GetPrefBoolEnc(u *User, k UserPrefKey) (bool, error)
- func (m UserModel) GetPrefInt(u *User, k UserPrefKey) (int, error)
- func (m UserModel) GetPrefInt64(u *User, k UserPrefKey) (int64, error)
- func (m UserModel) GetPrefInt64Enc(u *User, k UserPrefKey) (int64, error)
- func (m UserModel) GetPrefIntEnc(u *User, k UserPrefKey) (int, error)
- func (m UserModel) GetPrefString(u *User, k UserPrefKey) (string, error)
- func (m UserModel) GetPrefStringEnc(u *User, k UserPrefKey) (string, error)
- func (m UserModel) GetUsers() ([]*User, error)
- func (m UserModel) Insert(u *User) error
- func (m UserModel) PrefExists(u *User, k UserPrefKey) (bool, error)
- func (m UserModel) SetPref(u *User, k UserPrefKey, v interface{}) error
- func (m UserModel) SetPrefEnc(u *User, k UserPrefKey, v interface{}) error
- type UserPrefKey
- type UserReputation
- type UserReputationModel
- type UserStat
- type UserStatModel
Constants ¶
const SQLTimeout = time.Second * 1
SQLTimeout is the default timeout for SQL queries
Variables ¶
var ( // ErrGuildNotExistent should be used in case a requested guild was not found in the database ErrGuildNotExistent = errors.New("requested guild not existent in database") // ErrUserNotExistent should be used in case a requested user was not found in the database ErrUserNotExistent = errors.New("requested user not existent in database") // ErrGuildPrefNotExistent should be returned in case a guild preference is requested that does // not exist in the database ErrGuildPrefNotExistent = errors.New("requested guild preference not existent in database") // ErrUserPrefNotExistent should be returned in case a user preference is requested that does // not exist in the database ErrUserPrefNotExistent = errors.New("requested user preference not existent in database") // ErrTradeRouteNotExistent should be used in case a requested trade route was not found in the database ErrTradeRouteNotExistent = errors.New("requested trade route not existent in database") // ErrEditConflict should be used when an UPDATE to the database ran into a race-condition ErrEditConflict = errors.New("a conflict occurred while updating data") // ErrUserStatNotExistent should be used in case a requested user stat was not found in the database ErrUserStatNotExistent = errors.New("requested user stat not existent in database") // ErrDeedNotExistent should be used in case a requested deed was not found in the database ErrDeedNotExistent = errors.New("requested deed not existent in database") // ErrDeedDuplicate should be used in case a deed to be inserted into the database already exists ErrDeedDuplicate = errors.New("deed already existent in database") // ErrUserNil should be returned if the check for the *User returns nil ErrUserNil = errors.New("user pointer must not be nil:w") // ErrUserRepNotExistent should be used in case a requested user reputation was not found in the database ErrUserRepNotExistent = errors.New("requested user reputation not existent in database") )
List of model specific errors
Functions ¶
This section is empty.
Types ¶
type Deed ¶ added in v0.1.6
type Deed struct { ID int64 `json:"id"` DeedType DeedType `json:"deedType"` Description string `json:"description"` ValidFrom time.Time `json:"validFrom"` ValidThru time.Time `json:"validThru"` RewardType RewardType `json:"rewardType"` RewardAmount int `json:"rewardAmount"` RewardIcon string `json:"rewardIcon"` ImageURL string `json:"imageURL"` CreateTime time.Time `json:"createTime"` }
Deed represents the deed information in the database
type DeedModel ¶ added in v0.1.6
DeedModel wraps the connection pool.
func (DeedModel) GetByDeedID ¶ added in v0.1.6
GetByDeedID retrieves the Deed details from the database based on the given Deed ID
func (DeedModel) GetByDeedsAtTime ¶ added in v0.1.6
GetByDeedsAtTime retrieves the list of Deed details from the database based on a given time
type Guild ¶
type Guild struct { ID int64 `json:"id"` GuildID string `json:"guildId"` GuildName string `json:"guildName"` OwnerID string `json:"ownerId"` JoinedAt time.Time `json:"joinedAt"` SystemChannelID string `json:"systemChannelID"` EncryptionKey []byte `json:"-"` Version int `json:"-"` CreateTime time.Time `json:"createTime"` ModTime time.Time `json:"modTime"` }
Guild represents the guild information in the database
type GuildModel ¶
GuildModel wraps the connection pool.
func (GuildModel) AnnouceChannel ¶
func (m GuildModel) AnnouceChannel(g *Guild) string
AnnouceChannel will return the dedicated annouce channel or the system channel if no alternative is configured in the database
func (GuildModel) DecryptEncSecret ¶
func (m GuildModel) DecryptEncSecret(g *Guild) ([]byte, error)
DecryptEncSecret decrypts the guild specific encryption secret in the DB with the global encryption key
func (GuildModel) Delete ¶
func (m GuildModel) Delete(g *Guild) error
Delete removes a Guild from the database
func (GuildModel) GetByGuildID ¶
func (m GuildModel) GetByGuildID(i string) (*Guild, error)
GetByGuildID retrieves the Guild details from the database based on the given Guild ID
func (GuildModel) GetGuilds ¶
func (m GuildModel) GetGuilds() ([]*Guild, error)
GetGuilds returns a list of all guilds registered in the database
func (GuildModel) GetPrefBool ¶
func (m GuildModel) GetPrefBool(g *Guild, k GuildPrefKey) (bool, error)
GetPrefBool fetches a client-specific setting from the database as string type
func (GuildModel) GetPrefInt ¶
func (m GuildModel) GetPrefInt(g *Guild, k GuildPrefKey) (int, error)
GetPrefInt fetches a client-specific setting from the database as string type
func (GuildModel) GetPrefInt64 ¶
func (m GuildModel) GetPrefInt64(g *Guild, k GuildPrefKey) (int64, error)
GetPrefInt64 fetches a client-specific setting from the database as string type
func (GuildModel) GetPrefString ¶
func (m GuildModel) GetPrefString(g *Guild, k GuildPrefKey) (string, error)
GetPrefString fetches a client-specific setting from the database as string type
func (GuildModel) GetPrefStringEnc ¶
func (m GuildModel) GetPrefStringEnc(g *Guild, k GuildPrefKey) (string, error)
GetPrefStringEnc fetches an encrypted client-specific setting from the database as string type
func (GuildModel) Insert ¶
func (m GuildModel) Insert(g *Guild) error
Insert adds a new Guild into the database
func (GuildModel) PrefExists ¶
func (m GuildModel) PrefExists(g *Guild, k GuildPrefKey) (bool, error)
PrefExists checks if a guild preference is already present in the DB
func (GuildModel) SetPref ¶
func (m GuildModel) SetPref(g *Guild, k GuildPrefKey, v interface{}) error
SetPref stores a guild-specific setting in the database
func (GuildModel) SetPrefEnc ¶
func (m GuildModel) SetPrefEnc(g *Guild, k GuildPrefKey, v interface{}) error
SetPrefEnc stores an encrypted guild-specific setting in the database
type GuildPrefKey ¶
type GuildPrefKey string
GuildPrefKey represents a guild preferences identifier key
const ( // GuildPrefScheduledFlameheart is the setting for en-/disabling the scheduled Flameheart spam GuildPrefScheduledFlameheart GuildPrefKey = "scheduled_fh" // GuildPrefAnnounceChannel is an alternative announcement channel for the guild GuildPrefAnnounceChannel GuildPrefKey = "announce_channel" // GuildPrefAnnounceSoTSummary is set, when the guild allows the announcing of SoT play summaries GuildPrefAnnounceSoTSummary GuildPrefKey = "announce_sot_play_summary" )
List of possible GuildPrefKeys
type Model ¶
type Model struct { Deed *DeedModel Guild *GuildModel TradeRoute *TradeRouteModel User *UserModel UserReputation *UserReputationModel UserStats *UserStatModel }
Model is a collection of all available models
type RewardType ¶ added in v0.1.6
type RewardType string
RewardType is a wrapper for a string
const ( RewardGold RewardType = "gold" RewardDoubloons RewardType = "doubloons" )
Different reward types
type TradeRoute ¶
type TradeRoute struct { ID int64 `json:"id"` Outpost string `json:"outpost"` SoughtAfter string `json:"soughtAfter"` Surplus string `json:"surplus"` ValidThru time.Time `json:"validThru"` Version int `json:"-"` CreateTime time.Time `json:"createTime"` ModTime time.Time `json:"modTime"` }
TradeRoute represents the trade route information in the database
type TradeRouteModel ¶
TradeRouteModel wraps the connection pool.
func (TradeRouteModel) GetByOutpost ¶
func (m TradeRouteModel) GetByOutpost(o string) (*TradeRoute, error)
GetByOutpost retrieves the TradeRoute details from the database based on the given Outpost name
func (TradeRouteModel) GetTradeRoutes ¶
func (m TradeRouteModel) GetTradeRoutes() ([]*TradeRoute, error)
GetTradeRoutes returns a list of all trade routes registered in the database
func (TradeRouteModel) Insert ¶
func (m TradeRouteModel) Insert(t *TradeRoute) error
Insert adds a new TradeRoute into the database
func (TradeRouteModel) Update ¶
func (m TradeRouteModel) Update(t *TradeRoute) error
Update takes a given TradeRoute and updates the variable values in the database
type User ¶
type User struct { ID int64 `json:"id"` UserID string `json:"userId"` EncryptionKey []byte `json:"-"` Version int `json:"-"` CreateTime time.Time `json:"createTime"` ModTime time.Time `json:"modTime"` }
User represents the user information in the database
type UserModel ¶
UserModel wraps the connection pool.
func (UserModel) DecryptEncSecret ¶
DecryptEncSecret decrypts the user specific encryption secret in the DB with the global encryption key
func (UserModel) GetByUserID ¶
GetByUserID retrieves the User details from the database based on the given User ID
func (UserModel) GetPrefBool ¶
func (m UserModel) GetPrefBool(u *User, k UserPrefKey) (bool, error)
GetPrefBool fetches a client-specific setting from the database as string type
func (UserModel) GetPrefBoolEnc ¶
func (m UserModel) GetPrefBoolEnc(u *User, k UserPrefKey) (bool, error)
GetPrefBoolEnc fetches an encrypted client-specific setting from the database as string type
func (UserModel) GetPrefInt ¶
func (m UserModel) GetPrefInt(u *User, k UserPrefKey) (int, error)
GetPrefInt fetches a client-specific setting from the database as string type
func (UserModel) GetPrefInt64 ¶
func (m UserModel) GetPrefInt64(u *User, k UserPrefKey) (int64, error)
GetPrefInt64 fetches a client-specific setting from the database as string type
func (UserModel) GetPrefInt64Enc ¶
func (m UserModel) GetPrefInt64Enc(u *User, k UserPrefKey) (int64, error)
GetPrefInt64Enc fetches an encrypted client-specific setting from the database as string type
func (UserModel) GetPrefIntEnc ¶
func (m UserModel) GetPrefIntEnc(u *User, k UserPrefKey) (int, error)
GetPrefIntEnc fetches an encrypted client-specific setting from the database as string type
func (UserModel) GetPrefString ¶
func (m UserModel) GetPrefString(u *User, k UserPrefKey) (string, error)
GetPrefString fetches a client-specific setting from the database as string type
func (UserModel) GetPrefStringEnc ¶
func (m UserModel) GetPrefStringEnc(u *User, k UserPrefKey) (string, error)
GetPrefStringEnc fetches an encrypted client-specific setting from the database as string type
func (UserModel) PrefExists ¶
func (m UserModel) PrefExists(u *User, k UserPrefKey) (bool, error)
PrefExists checks if a user preference is already present in the DB
func (UserModel) SetPref ¶
func (m UserModel) SetPref(u *User, k UserPrefKey, v interface{}) error
SetPref stores a user-specific setting in the database
func (UserModel) SetPrefEnc ¶
func (m UserModel) SetPrefEnc(u *User, k UserPrefKey, v interface{}) error
SetPrefEnc stores an encrypted user-specific setting in the database
type UserPrefKey ¶
type UserPrefKey string
UserPrefKey represents a user preferences identifier key
const ( // UserPrefSoTAuthToken is the authentication token for Sea of Thieves UserPrefSoTAuthToken UserPrefKey = "rat_token" UserPrefSoTAuthTokenExpiration UserPrefKey = "rat_token_expire" UserPrefSoTAuthTokenNotified UserPrefKey = "rat_expiry_notified" UserPrefPlaysSoT UserPrefKey = "plays_sot" UserPrefPlaysSoTStartTime UserPrefKey = "plays_sot_start" )
List of possible UserPrefKeys
type UserReputation ¶ added in v0.2.8
type UserReputation struct { ID int64 `json:"id"` UserID int64 `json:"userId"` Emissary string `json:"emissary"` Motto string `json:"motto"` Rank string `json:"rank"` Level int64 `json:"lvl"` Experience int64 `json:"experience"` NextLevel int64 `json:"nextLevel"` ExperienceNextLevel int64 `json:"experienceNextLevel"` TitlesTotal int64 `json:"titlesTotal"` TitlesUnlocked int64 `json:"titlesUnlocked"` EmblemsTotal int64 `json:"EmblemsTotal"` EmblemsUnlocked int64 `json:"EmblemsUnlocked"` ItemsTotal int64 `json:"ItemsTotal"` ItemsUnlocked int64 `json:"ItemsUnlocked"` CreateTime time.Time `json:"createTime"` }
UserReputation represents the user reputation in the database
type UserReputationModel ¶ added in v0.2.8
UserReputationModel wraps the connection pool.
func (UserReputationModel) GetByUserID ¶ added in v0.2.8
func (m UserReputationModel) GetByUserID(i int64, e string) (*UserReputation, error)
GetByUserID retrieves the User details from the database based on the given User ID
func (UserReputationModel) GetByUserIDAtTime ¶ added in v0.2.8
func (m UserReputationModel) GetByUserIDAtTime(i int64, e string, t time.Time) (*UserReputation, error)
GetByUserIDAtTime retrieves the User details from the database based on the given User ID at a specific point of time
func (UserReputationModel) Insert ¶ added in v0.2.8
func (m UserReputationModel) Insert(ur *UserReputation) error
Insert adds a new User into the database
type UserStat ¶
type UserStat struct { ID int64 `json:"id"` UserID int64 `json:"userId"` Title string `json:"title"` Gold int64 `json:"gold"` Doubloons int64 `json:"doubloons"` AncientCoins int64 `json:"ancientCoins"` KrakenDefeated int64 `json:"krakenDefeated"` MegalodonEnounter int64 `json:"megalodonEnounter"` ChestsHandedIn int64 `json:"chestsHandedIn"` ShipsSunk int64 `json:"shipsSunk"` VomittedTimes int64 `json:"vomittedTimes"` DistanceSailed int64 `json:"distanceSailed"` CreateTime time.Time `json:"createTime"` }
UserStat represents the user statistics in the database
type UserStatModel ¶
UserStatModel wraps the connection pool.
func (UserStatModel) GetByUserID ¶
func (m UserStatModel) GetByUserID(i int64) (*UserStat, error)
GetByUserID retrieves the User details from the database based on the given User ID
func (UserStatModel) GetByUserIDAtTime ¶
GetByUserIDAtTime retrieves the User details from the database based on the given User ID at a specific point of time
func (UserStatModel) Insert ¶
func (m UserStatModel) Insert(us *UserStat) error
Insert adds a new User into the database