Documentation
¶
Index ¶
- func DbPool(ctx context.Context, maxConnection int32, logger tracelog.Logger, ...) (*pgxpool.Pool, error)
- type DBTX
- type Flag
- type Queries
- func (q *Queries) AssignQuestionToTeam(ctx context.Context, teamID *string) error
- func (q *Queries) CheckIfAnswered(ctx context.Context, id string) (bool, error)
- func (q *Queries) GetFlag(ctx context.Context, id string) (Flag, error)
- func (q *Queries) GetTeam(ctx context.Context) (Team, error)
- func (q *Queries) GetTeamBySecret(ctx context.Context, secret string) (Team, error)
- func (q *Queries) MarkFlagAsCorrect(ctx context.Context, id string) error
- func (q *Queries) MarkFlagAsIncorrect(ctx context.Context, id string) error
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type Team
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DbPool ¶
func DbPool(ctx context.Context, maxConnection int32, logger tracelog.Logger, logLevel string) (*pgxpool.Pool, error)
NOTE: tracing support for tracelog(pgx)
https://github.com/jackc/pgx/discussions/1677#discussioncomment-8815982
NOTE: TraceLog doesn't take logLevel as we have in our logging library it
takes in a number, we will need to add a mapping fucntion, for now we're just keeping the argument for nothing but its OK
Types ¶
type Flag ¶
type Flag struct { ID string `json:"id"` Question string `json:"question"` Answer string `json:"answer"` AnswerOption []byte `json:"answer_option"` Score int32 `json:"score"` SeqNum int32 `json:"seq_num"` Correct *bool `json:"correct"` TeamID *string `json:"team_id"` CreatedAt pgtype.Timestamp `json:"created_at"` UpdatedAt pgtype.Timestamp `json:"updated_at"` }
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AssignQuestionToTeam ¶
AssignQuestionToTeam
WITH to_update AS ( SELECT id FROM flag WHERE team_id IS NULL LIMIT 5) UPDATE flag SET team_id = $1 WHERE id IN ( SELECT id FROM to_update)
func (*Queries) CheckIfAnswered ¶
CheckIfAnswered
SELECT CASE WHEN correct IS NOT NULL AND id = $1 THEN TRUE ELSE FALSE END FROM flag WHERE id = $1
func (*Queries) GetFlag ¶
GetFlag
SELECT id, question, answer, answer_option, score, seq_num, correct, team_id, created_at, updated_at FROM flag WHERE id = $1
func (*Queries) GetTeamBySecret ¶
GetTeamBySecret
SELECT id, team_name, secret, map_url FROM team WHERE secret = $1
func (*Queries) MarkFlagAsIncorrect ¶
MarkFlagAsIncorrect
UPDATE flag SET correct = FALSE WHERE id = $1
Click to show internal directories.
Click to hide internal directories.