everybody loves a refactor
This commit is contained in:
@@ -53,13 +53,13 @@ func CreateUser(ctx context.Context, tx bun.Tx, username string, discorduser *di
|
||||
}
|
||||
|
||||
// GetUserByID queries the database for a user matching the given ID
|
||||
// Returns nil, nil if no user is found
|
||||
// Returns a BadRequestNotFound error if no user is found
|
||||
func GetUserByID(ctx context.Context, tx bun.Tx, id int) (*User, error) {
|
||||
return GetByID[User](tx, id).Get(ctx)
|
||||
}
|
||||
|
||||
// GetUserByUsername queries the database for a user matching the given username
|
||||
// Returns nil, nil if no user is found
|
||||
// Returns a BadRequestNotFound error if no user is found
|
||||
func GetUserByUsername(ctx context.Context, tx bun.Tx, username string) (*User, error) {
|
||||
if username == "" {
|
||||
return nil, errors.New("username not provided")
|
||||
@@ -68,7 +68,7 @@ func GetUserByUsername(ctx context.Context, tx bun.Tx, username string) (*User,
|
||||
}
|
||||
|
||||
// GetUserByDiscordID queries the database for a user matching the given discord id
|
||||
// Returns nil, nil if no user is found
|
||||
// Returns a BadRequestNotFound error if no user is found
|
||||
func GetUserByDiscordID(ctx context.Context, tx bun.Tx, discordID string) (*User, error) {
|
||||
if discordID == "" {
|
||||
return nil, errors.New("discord_id not provided")
|
||||
|
||||
Reference in New Issue
Block a user