orm

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DB

func DB() *bun.DB

func QueryGetPlatformUser

func QueryGetPlatformUser(idb bun.IDB, model any, platformID int, platformUserID string) *bun.SelectQuery

func QueryGetPlatformUsers

func QueryGetPlatformUsers(idb bun.IDB, model any) *bun.SelectQuery

func QueryGetUser

func QueryGetUser(idb bun.IDB, model any, userID int64) *bun.SelectQuery

func QueryGetUsers

func QueryGetUsers(idb bun.IDB, model any) *bun.SelectQuery

Types

type Account

type Account struct {
	Model          `bun:",extend"`
	gw2api.Account `bun:",extend"`
	UserID         int64
}

func GetUserAccounts

func GetUserAccounts(userID int64) (accounts []Account, err error)

func (*Account) Persist

func (acc *Account) Persist(tx bun.IDB) (err error)

type Ban

type Ban struct {
	Model         `bun:",extend"`
	api.Ban       `bun:",extend"`
	bun.BaseModel `bun:"table:bans,alias:bans"`
}

Ban contains information on length and why an account was banned

type Model

type Model struct {
	DbCreated time.Time `bun:",nullzero,notnull,default:current_timestamp,scanonly"`
	DbUpdated time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

func (*Model) BeforeAppendModel

func (m *Model) BeforeAppendModel(ctx context.Context, query bun.Query) error
type PlatformLink struct {
	Model            `bun:",extend"`
	api.PlatformLink `bun:",extend"`
}
func GetPlatformLink(platformID int, platformUserId string) (link PlatformLink, err error)
func GetUserPlatformLinks(userID int64) (links []PlatformLink, err error)

type TokenInfo

type TokenInfo struct {
	Model            `bun:",extend"`
	gw2api.TokenInfo `bun:",extend"`

	LastSuccess time.Time
	APIKey      string `bun:"api_key"`
	AccountID   string
}

func FindLastUpdatedAPIKey

func FindLastUpdatedAPIKey(ignoreOlderThan int) (token TokenInfo, err error)

func FindUserAPIKeys

func FindUserAPIKeys(userID int64, ignoreOlderThan int) (tokens []TokenInfo, err error)

func (*TokenInfo) Persist

func (token *TokenInfo) Persist(tx bun.IDB) (err error)

func (*TokenInfo) UpdateLastAttemptedUpdate

func (token *TokenInfo) UpdateLastAttemptedUpdate() (err error)

func (*TokenInfo) UpdateLastSuccessfulUpdate

func (token *TokenInfo) UpdateLastSuccessfulUpdate() (err error)

Jump to

Keyboard shortcuts

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