database

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB() (*gorp.DbMap, error)

NewDB はMySQLへ接続し、gorpのマッピングオブジェクトを生成します。

Types

type AuthRepository

type AuthRepository struct {
	// contains filtered or unexported fields
}

AuthRepository は repository.AuthRepository を満たす構造体です

func NewAuthRepository

func NewAuthRepository(dbMap *gorp.DbMap) *AuthRepository

NewAuthRepository はAuthRepositoryのポインタを生成する関数です

func (AuthRepository) DeleteState

func (r AuthRepository) DeleteState(state string) error

DeleteState はstateをキーにしてStateTempを削除します。

func (AuthRepository) FindStateByState

func (r AuthRepository) FindStateByState(state string) (*entity.AuthState, error)

FindStateByState はstateをキーしてStateTempを取得する。

func (AuthRepository) GetTokenByUserID

func (r AuthRepository) GetTokenByUserID(userID string) (*oauth2.Token, error)

GetTokenByUserID は与えられたユーザのOAuth2のトークンを取得します。

func (AuthRepository) GetUserIDFromSession

func (r AuthRepository) GetUserIDFromSession(sessionID string) (string, error)

GetUserIDFromSession はセッションIDからユーザIDを取得します。

func (AuthRepository) StoreORUpdateToken

func (r AuthRepository) StoreORUpdateToken(userID string, token *oauth2.Token) error

StoreORUpdateToken は既にトークンが存在する場合は更新し、存在しない場合は新規に保存します。

func (AuthRepository) StoreSession

func (r AuthRepository) StoreSession(sessionID, userID string) error

StoreSession はセッション情報を保存します。

func (AuthRepository) StoreState

func (r AuthRepository) StoreState(authState *entity.AuthState) error

StoreState はauthStateを保存します。

type SessionRepository

type SessionRepository struct {
	// contains filtered or unexported fields
}

SessionRepository は repository.SessionRepository を満たす構造体です

func NewSessionRepository

func NewSessionRepository(dbMap *gorp.DbMap) *SessionRepository

NewSessionRepository はSessionRepositoryのポインタを生成する関数です

func (*SessionRepository) ArchiveSessionsForBatch

func (r *SessionRepository) ArchiveSessionsForBatch() error

ArchiveSessionsForBatch は以下の条件に当てはまるSessionのstateをArchivedに変更します // - 作成から3日以上が経過している。もしくはArchiveが解除されてから3日以上が経過している

func (*SessionRepository) DoInTx added in v0.2.0

func (r *SessionRepository) DoInTx(ctx context.Context, f func(ctx context.Context) (interface{}, error)) (interface{}, error)

DoInTx はトランザクションの中でデータベースにアクセスするためのラッパー関数です。

func (*SessionRepository) FindByID

func (r *SessionRepository) FindByID(ctx context.Context, id string) (*entity.Session, error)

FindByID は指定されたIDを持つsessionをDBから取得します

func (*SessionRepository) FindByIDForUpdate added in v0.2.0

func (r *SessionRepository) FindByIDForUpdate(ctx context.Context, id string) (*entity.Session, error)

FindByIDForUpdate は指定されたIDを持つsessionをDBから取得します

func (*SessionRepository) FindCreatorTokenBySessionID

func (r *SessionRepository) FindCreatorTokenBySessionID(ctx context.Context, sessionID string) (*oauth2.Token, string, error)

FindCreatorTokenBySessionID はSessionIDからCreatorのTokenを取得します

func (*SessionRepository) StoreQueueTrack

func (r *SessionRepository) StoreQueueTrack(ctx context.Context, queueTrack *entity.QueueTrackToStore) error

StoreQueueTrack はQueueTrackをDBに挿入します。

func (*SessionRepository) StoreSession

func (r *SessionRepository) StoreSession(ctx context.Context, session *entity.Session) error

StoreSession はSessionをDBに挿入します。

func (*SessionRepository) Update

func (r *SessionRepository) Update(ctx context.Context, session *entity.Session) error

Update はセッションの情報を更新します。

type TransactionDAO added in v0.2.0

type TransactionDAO interface {
	SelectOne(holder interface{}, query string, args ...interface{}) error
	Insert(list ...interface{}) error
	Update(list ...interface{}) (int64, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

UserRepository は repository.UserRepository を満たす構造体です

func NewUserRepository

func NewUserRepository(dbMap *gorp.DbMap) *UserRepository

NewUserRepository はUserRepositoryのポインタを生成する関数です

func (*UserRepository) FindByID

func (r *UserRepository) FindByID(id string) (*entity.User, error)

FindByID は指定されたIDを持つユーザをDBから取得します

func (*UserRepository) FindBySpotifyUserID

func (r *UserRepository) FindBySpotifyUserID(spotifyUserID string) (*entity.User, error)

FindBySpotifyUserID はspotifyUserIDを持つユーザを取得します。

func (*UserRepository) Store

func (r *UserRepository) Store(user *entity.User) error

Store はユーザを新規保存します。

func (*UserRepository) Update

func (r *UserRepository) Update(user *entity.User) error

Update はユーザの情報を更新します。

Jump to

Keyboard shortcuts

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