Documentation ¶
Index ¶
- Variables
- func BuildIn(num int, start int) string
- func Delete(ctx context.Context, tx pgx.Tx, cfg *CommonDBConfig) error
- func GetDBIDFromUUID(ctx context.Context, pool *pgxpool.Pool, cfg *CommonDBConfig) (int64, error)
- func GetGameDBIDFromUUID(ctx context.Context, tx pgx.Tx, uuid string) (int64, error)
- func GetGameInfo(ctx context.Context, tx pgx.Tx, gameId int) (*macondopb.GameHistory, *ipc.GameRequest, string, error)
- func GetPuzzleDBIDFromUUID(ctx context.Context, tx pgx.Tx, uuid string) (int64, error)
- func GetUserBy(ctx context.Context, tx pgx.Tx, cfg *CommonDBConfig) (*entity.User, error)
- func GetUserDBIDFromUUID(ctx context.Context, tx pgx.Tx, uuid string) (int64, error)
- func GetUserRating(ctx context.Context, tx pgx.Tx, userId int64, ratingKey entity.VariantKey) (*entity.SingleRating, error)
- func GetUserRatingWithPool(ctx context.Context, pool *pgxpool.Pool, userId int64, ...) (*entity.SingleRating, error)
- func GetUserStats(ctx context.Context, tx pgx.Tx, userId int64, ratingKey entity.VariantKey) (*entity.Stats, error)
- func GetUserStatsWithPool(ctx context.Context, pool *pgxpool.Pool, userId int64, ...) (*entity.Stats, error)
- func GetUserUUIDFromDBID(ctx context.Context, tx pgx.Tx, DBID int64) (string, error)
- func GetUsernameFromUUID(ctx context.Context, tx pgx.Tx, uuid string) (string, error)
- func InitializeUserRating(ctx context.Context, tx pgx.Tx, userId int64) error
- func InitializeUserStats(ctx context.Context, tx pgx.Tx, userId int64) error
- func OpenDB(host, port, name, user, password, sslmode string) (*pgxpool.Pool, error)
- func OpenTestingDB(pkg string) (*pgxpool.Pool, error)
- func PostgresConnDSN(host, port, name, user, password, sslmode string) string
- func PostgresConnUri(host, port, name, user, password, sslmode string) string
- func RecreateTestDB(pkg string) error
- func TeardownTestDB(pkg string) error
- func TestDBName(pkg string) string
- func TestingPostgresConnDSN(pkg string) string
- func TestingPostgresConnUri(pkg string) string
- func Update(ctx context.Context, tx pgx.Tx, columns []string, args []interface{}, ...) error
- func UpdateUserRating(ctx context.Context, tx pgx.Tx, userId int64, ratingKey entity.VariantKey, ...) error
- func UpdateUserStats(ctx context.Context, tx pgx.Tx, userId int64, ratingKey entity.VariantKey, ...) error
- func UpdateWithPool(ctx context.Context, pool *pgxpool.Pool, columns []string, args []interface{}, ...) error
- type CommonDBConfig
- type RowIterator
- type RowsAffectedType
- type SelectByType
- type TableType
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTxOptions = pgx.TxOptions{
IsoLevel: pgx.ReadCommitted,
AccessMode: pgx.ReadWrite,
DeferrableMode: pgx.Deferrable,
}
View Source
var GormLogger logger.Interface
View Source
var InitialRating = &entity.SingleRating{ Rating: float64(glicko.InitialRating), RatingDeviation: float64(glicko.InitialRatingDeviation), Volatility: glicko.InitialVolatility, }
View Source
var MigrationsPath = os.Getenv("DB_MIGRATIONS_PATH")
View Source
var RepeatableReadTxOptions = pgx.TxOptions{
IsoLevel: pgx.RepeatableRead,
AccessMode: pgx.ReadWrite,
DeferrableMode: pgx.Deferrable,
}
View Source
var SelectByTypeToString = map[SelectByType]string{ SelectByUUID: "uuid", SelectByID: "id", SelectByUserID: "user_id", SelectByUsername: "lower(username)", SelectByEmail: "lower(email)", SelectByAPIKey: "api_key", SelectBySeekerID: "seeker", SelectBySeekerConnID: "seeker_conn_id", SelectByReceiverID: "receiver", SelectByReceiverConnID: "receiver_conn_id", }
View Source
var TableTypeToString = map[TableType]string{ UsersTable: "users", ProfilesTable: "profiles", GamesTable: "games", PuzzlesTable: "puzzles", SoughtGamesTable: "soughtgames", }
View Source
var TestDBHost = os.Getenv("TEST_DB_HOST")
View Source
var TestDBPassword = os.Getenv("DB_PASSWORD")
View Source
var TestDBPort = os.Getenv("DB_PORT")
View Source
var TestDBPrefix = os.Getenv("TEST_DB_PREFIX")
View Source
var TestDBSSLMode = os.Getenv("DB_SSL_MODE")
View Source
var TestDBUser = os.Getenv("DB_USER")
Functions ¶
func GetDBIDFromUUID ¶
func GetGameDBIDFromUUID ¶
func GetGameInfo ¶
func GetGameInfo(ctx context.Context, tx pgx.Tx, gameId int) (*macondopb.GameHistory, *ipc.GameRequest, string, error)
func GetPuzzleDBIDFromUUID ¶
func GetUserDBIDFromUUID ¶
func GetUserRating ¶
func GetUserRating(ctx context.Context, tx pgx.Tx, userId int64, ratingKey entity.VariantKey) (*entity.SingleRating, error)
func GetUserRatingWithPool ¶
func GetUserRatingWithPool(ctx context.Context, pool *pgxpool.Pool, userId int64, ratingKey entity.VariantKey) (*entity.SingleRating, error)
func GetUserStats ¶
func GetUserStatsWithPool ¶
func GetUserUUIDFromDBID ¶
func GetUsernameFromUUID ¶
func InitializeUserRating ¶
func InitializeUserStats ¶
func PostgresConnDSN ¶
PostgresConnDSN is obsolete and only for Gorm. Remove once we get rid of gorm.
func PostgresConnUri ¶
func RecreateTestDB ¶
func TeardownTestDB ¶
func TestDBName ¶
func TestingPostgresConnDSN ¶
XXX: Delete me after removing Gorm
func TestingPostgresConnUri ¶
func Update ¶
func Update(ctx context.Context, tx pgx.Tx, columns []string, args []interface{}, cfg *CommonDBConfig) error
func UpdateUserRating ¶
func UpdateUserRating(ctx context.Context, tx pgx.Tx, userId int64, ratingKey entity.VariantKey, newRating *entity.SingleRating) error
func UpdateUserStats ¶
func UpdateWithPool ¶
Types ¶
type CommonDBConfig ¶
type CommonDBConfig struct { SelectByType SelectByType TableType TableType RowsAffectedType RowsAffectedType Value interface{} SetUpdatedAt bool IncludeProfile bool }
type RowIterator ¶
type RowsAffectedType ¶
type RowsAffectedType int
const ( AnyRowsAffected RowsAffectedType = iota AtMostOneRowAffected ExactlyOneRowAffected AtLeastOneRowAffected )
type SelectByType ¶
type SelectByType int
const ( SelectByUUID SelectByType = iota SelectByID SelectByUserID SelectByUsername SelectByEmail SelectByAPIKey SelectBySeekerID SelectBySeekerConnID SelectByReceiverID SelectByReceiverConnID )
Click to show internal directories.
Click to hide internal directories.