database

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 10 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) FindByID

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

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

func (*SessionRepository) FindCreatorTokenBySessionID

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

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

func (*SessionRepository) StoreQueueTrack

func (r *SessionRepository) StoreQueueTrack(queueTrack *entity.QueueTrackToStore) error

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

func (*SessionRepository) StoreSession

func (r *SessionRepository) StoreSession(session *entity.Session) error

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

func (*SessionRepository) Update

func (r *SessionRepository) Update(session *entity.Session) error

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

func (*SessionRepository) UpdateWithExpiredAt

func (r *SessionRepository) UpdateWithExpiredAt(session *entity.Session, newExpiredAt time.Time) error

UpdateWithExpiredAt はセッションの情報を更新し、同時にExpiredAtを更新します。

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