Documentation ¶
Overview ¶
Package models contains the database interaction model code
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Package models contains the database interaction model code ¶
GENERATED BY GOSCHEMA. DO NOT EDIT.
Index ¶
- Variables
- func InsertManyCourseDetailss(db DB, ms ...*CourseDetails) error
- func InsertManyCourses(db DB, ms ...*Course) error
- func InsertManyHoleStatss(db DB, ms ...*HoleStats) error
- func InsertManyHoles(db DB, ms ...*Hole) error
- func InsertManyRoundHitStatss(db DB, ms ...*RoundHitStats) error
- func InsertManyRoundStatss(db DB, ms ...*RoundStats) error
- func InsertManyRounds(db DB, ms ...*Round) error
- func InsertManyUsers(db DB, ms ...*User) error
- func IsKeySet(x interface{}) bool
- type Course
- type CourseDetails
- func (m *CourseDetails) Delete(db DB) error
- func (m *CourseDetails) GetCourse(db DB) (*Course, error)
- func (m *CourseDetails) Insert(db DB) error
- func (m *CourseDetails) InsertWithUpdate(db DB) error
- func (m *CourseDetails) IsPrimaryKeySet() bool
- func (m *CourseDetails) Save(db DB) error
- func (m *CourseDetails) SaveOrUpdate(db DB) error
- func (m *CourseDetails) Update(db DB) error
- type DB
- type DBTransactionHandler
- type DBTransactioner
- type Deletable
- type Hole
- func (m *Hole) Delete(db DB) error
- func (m *Hole) GetCourseDetails(db DB) (*CourseDetails, error)
- func (m *Hole) Insert(db DB) error
- func (m *Hole) InsertWithUpdate(db DB) error
- func (m *Hole) IsPrimaryKeySet() bool
- func (m *Hole) Save(db DB) error
- func (m *Hole) SaveOrUpdate(db DB) error
- func (m *Hole) Update(db DB) error
- type HoleStats
- func (m *HoleStats) Delete(db DB) error
- func (m *HoleStats) GetHole(db DB) (*Hole, error)
- func (m *HoleStats) Insert(db DB) error
- func (m *HoleStats) InsertWithUpdate(db DB) error
- func (m *HoleStats) IsPrimaryKeySet() bool
- func (m *HoleStats) Save(db DB) error
- func (m *HoleStats) SaveOrUpdate(db DB) error
- func (m *HoleStats) Update(db DB) error
- type LoggableDBTransactionHandler
- type PostDeletable
- type PostSaveable
- type PreDeletable
- type PreSaveable
- type Round
- func (m *Round) Delete(db DB) error
- func (m *Round) GetUser(db DB) (*User, error)
- func (m *Round) Insert(db DB) error
- func (m *Round) InsertWithUpdate(db DB) error
- func (m *Round) IsPrimaryKeySet() bool
- func (m *Round) Save(db DB) error
- func (m *Round) SaveOrUpdate(db DB) error
- func (m *Round) Update(db DB) error
- type RoundHitStats
- func (m *RoundHitStats) Delete(db DB) error
- func (m *RoundHitStats) GetRoundStats(db DB) (*RoundStats, error)
- func (m *RoundHitStats) Insert(db DB) error
- func (m *RoundHitStats) InsertWithUpdate(db DB) error
- func (m *RoundHitStats) IsPrimaryKeySet() bool
- func (m *RoundHitStats) Save(db DB) error
- func (m *RoundHitStats) SaveOrUpdate(db DB) error
- func (m *RoundHitStats) Update(db DB) error
- type RoundStats
- func (m *RoundStats) Delete(db DB) error
- func (m *RoundStats) GetRound(db DB) (*Round, error)
- func (m *RoundStats) Insert(db DB) error
- func (m *RoundStats) InsertWithUpdate(db DB) error
- func (m *RoundStats) IsPrimaryKeySet() bool
- func (m *RoundStats) Save(db DB) error
- func (m *RoundStats) SaveOrUpdate(db DB) error
- func (m *RoundStats) Update(db DB) error
- type Saveable
- type SetLogger
- type TransactionFunc
- type TransactionHandler
- type Transactioner
- type User
- type XODB
Constants ¶
This section is empty.
Variables ¶
var ( HoleStatsFairwayHitHIT = "HIT" HoleStatsFairwayHitLEFT = "LEFT" HoleStatsFairwayHitRIGHT = "RIGHT" HoleStatsFairwayHitSHORT = "SHORT" HoleStatsFairwayHitLONG = "LONG" HoleStatsFairwayHitNOTAPPLICABLE = "NOT_APPLICABLE" )
Valid values for the 'FairwayHit' enum column
var ( HoleStatsGreenHitHIT = "HIT" HoleStatsGreenHitLEFT = "LEFT" HoleStatsGreenHitRIGHT = "RIGHT" HoleStatsGreenHitSHORT = "SHORT" HoleStatsGreenHitLONG = "LONG" )
Valid values for the 'GreenHit' enum column
var ( RoundHitStatsTypeGREEN = "GREEN" RoundHitStatsTypeFAIRWAY = "FAIRWAY" )
Valid values for the 'Type' enum column
var CourseColumns = []string{"Id", "Name", "RoundId"}
CourseColumns is the sorted column names for the type Course
var CourseDetailsColumns = []string{"BackNineMeters", "BackNinePar", "BackNineYards", "CourseId", "CourseRating", "FrontNineMeters", "FrontNinePar", "FrontNineYards", "Id", "Marker", "Slope", "TotalMeters", "TotalPar", "TotalYards"}
CourseDetailsColumns is the sorted column names for the type CourseDetails
var DBLog = func(string, ...any) {}
DBLog provides the log func used by generated queries.
var DatabaseLatency = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "database_latency", Help: "Duration of database queries", }, []string{"query"}, )
DatabaseLatency is the duration of database queries.
var ErrConstraintViolation = errors.New("constraint violation")
ErrConstraintViolation is returned if a constraint is violated
var ErrDuplicate = errors.New("duplicate entry")
ErrDuplicate is returned if a duplicate entry is found
var ErrNoAffectedRows = errors.New("no affected rows")
ErrNoAffectedRows is returned if a model update affected no rows
var HoleColumns = []string{"CourseDetailsId", "DistanceMeters", "DistanceYards", "Id", "Number", "Par", "Stroke"}
HoleColumns is the sorted column names for the type Hole
var HoleStatsColumns = []string{"FairwayHit", "GreenHit", "HoleId", "Id", "Penalties", "PinLocation", "Putts", "Score"}
HoleStatsColumns is the sorted column names for the type HoleStats
var RoundColumns = []string{"Id", "TeeTime", "UserId"}
RoundColumns is the sorted column names for the type Round
var RoundHitStatsColumns = []string{"Count", "Id", "Miss", "RoundStatsId", "Type"}
RoundHitStatsColumns is the sorted column names for the type RoundHitStats
var RoundStatsColumns = []string{"AvgFairwaysHit", "AvgGreensHit", "AvgPar3", "AvgPar4", "AvgPar5", "AvgPutts", "Id", "Penalties", "RoundId"}
RoundStatsColumns is the sorted column names for the type RoundStats
var UserColumns = []string{"Id", "LastLogin", "Name", "Password", "Username"}
UserColumns is the sorted column names for the type User
var XOLog = func(msg string, args ...any) { DBLog(msg, args...) }
XOLog is a compat shim for DBLog
Functions ¶
func InsertManyCourseDetailss ¶
func InsertManyCourseDetailss(db DB, ms ...*CourseDetails) error
func InsertManyCourses ¶
func InsertManyHoleStatss ¶
func InsertManyHoles ¶
func InsertManyRoundHitStatss ¶
func InsertManyRoundHitStatss(db DB, ms ...*RoundHitStats) error
func InsertManyRoundStatss ¶
func InsertManyRoundStatss(db DB, ms ...*RoundStats) error
func InsertManyRounds ¶
func InsertManyUsers ¶
Types ¶
type Course ¶
type Course struct { Id int `db:"id,autoinc,pk"` RoundId int `db:"round_id"` Name string `db:"name"` }
Course represents a row from 'course'.
func (*Course) InsertWithUpdate ¶
InsertWithUpdate inserts the Course to the database, and tries to update on unique constraint violations.
func (*Course) IsPrimaryKeySet ¶
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*Course) SaveOrUpdate ¶
SaveOrUpdate saves the Course to the database, but tries to update on unique constraint violations.
type CourseDetails ¶
type CourseDetails struct { Id int `db:"id,autoinc,pk"` CourseId int `db:"course_id"` Marker usql.NullString `db:"marker"` Slope int `db:"slope"` CourseRating float64 `db:"course_rating"` FrontNinePar int `db:"front_nine_par"` BackNinePar int `db:"back_nine_par"` TotalPar int `db:"total_par"` FrontNineYards int `db:"front_nine_yards"` BackNineYards int `db:"back_nine_yards"` TotalYards int `db:"total_yards"` FrontNineMeters int `db:"front_nine_meters"` BackNineMeters int `db:"back_nine_meters"` TotalMeters int `db:"total_meters"` }
CourseDetails represents a row from 'course_details'.
func CourseDetailsById ¶
func CourseDetailsById(db DB, id int) (*CourseDetails, error)
CourseDetailsById retrieves a row from 'course_details' as a CourseDetails.
Generated from primary key.
func (*CourseDetails) Delete ¶
func (m *CourseDetails) Delete(db DB) error
Delete deletes the CourseDetails from the database.
func (*CourseDetails) GetCourse ¶
func (m *CourseDetails) GetCourse(db DB) (*Course, error)
GetCourse Gets an instance of Course
Generated from constraint course_details_course_id_fk
func (*CourseDetails) Insert ¶
func (m *CourseDetails) Insert(db DB) error
Insert inserts the CourseDetails to the database.
func (*CourseDetails) InsertWithUpdate ¶
func (m *CourseDetails) InsertWithUpdate(db DB) error
InsertWithUpdate inserts the CourseDetails to the database, and tries to update on unique constraint violations.
func (*CourseDetails) IsPrimaryKeySet ¶
func (m *CourseDetails) IsPrimaryKeySet() bool
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*CourseDetails) Save ¶
func (m *CourseDetails) Save(db DB) error
Save saves the CourseDetails to the database.
func (*CourseDetails) SaveOrUpdate ¶
func (m *CourseDetails) SaveOrUpdate(db DB) error
SaveOrUpdate saves the CourseDetails to the database, but tries to update on unique constraint violations.
func (*CourseDetails) Update ¶
func (m *CourseDetails) Update(db DB) error
Update updates the CourseDetails in the database.
type DB ¶
type DB interface { Exec(string, ...any) (sql.Result, error) Query(string, ...any) (*sql.Rows, error) QueryRow(string, ...any) *sql.Row // Additional sqlx methods we like Get(dest any, query string, args ...interface{}) error Select(dest any, query string, args ...interface{}) error }
DB is the common interface for database operations
This should work with database/sql.DB and database/sql.Tx.
type DBTransactionHandler ¶
type DBTransactionHandler struct {
// contains filtered or unexported fields
}
DBTransactionHandler handles a transaction that will return any error.
func NewDBTransactionHandler ¶
func NewDBTransactionHandler(db Transactioner) *DBTransactionHandler
NewDBTransactionHandler returns a configured instance of DBTransactionHandler
func (*DBTransactionHandler) Handle ¶
func (th *DBTransactionHandler) Handle(f TransactionFunc) error
Handle implements the TransactionHandler interface.
type DBTransactioner ¶
type DBTransactioner interface { DB Transactioner }
DBTransactioner is the interface that database connections that can utilise transactions should implement.
type Deletable ¶
Deletable is the interface implemented by types which can delete themselves from the database.
type Hole ¶
type Hole struct { Id int `db:"id,autoinc,pk"` CourseDetailsId int `db:"course_details_id"` Number int `db:"number"` Par int `db:"par"` Stroke int `db:"stroke"` DistanceYards int `db:"distance_yards"` DistanceMeters int `db:"distance_meters"` }
Hole represents a row from 'hole'.
func (*Hole) GetCourseDetails ¶
func (m *Hole) GetCourseDetails(db DB) (*CourseDetails, error)
GetCourseDetails Gets an instance of CourseDetails
Generated from constraint hole_course_details_id_fk
func (*Hole) InsertWithUpdate ¶
InsertWithUpdate inserts the Hole to the database, and tries to update on unique constraint violations.
func (*Hole) IsPrimaryKeySet ¶
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*Hole) SaveOrUpdate ¶
SaveOrUpdate saves the Hole to the database, but tries to update on unique constraint violations.
type HoleStats ¶
type HoleStats struct { Id int `db:"id,autoinc,pk"` HoleId int `db:"hole_id"` Score int `db:"score"` FairwayHit usql.Enum `db:"fairway_hit"` GreenHit usql.Enum `db:"green_hit"` PinLocation string `db:"pin_location"` Putts int `db:"putts"` Penalties int `db:"penalties"` }
HoleStats represents a row from 'hole_stats'.
func HoleStatsById ¶
HoleStatsById retrieves a row from 'hole_stats' as a HoleStats.
Generated from primary key.
func (*HoleStats) GetHole ¶
GetHole Gets an instance of Hole
Generated from constraint hole_stats_hole_id_fk
func (*HoleStats) InsertWithUpdate ¶
InsertWithUpdate inserts the HoleStats to the database, and tries to update on unique constraint violations.
func (*HoleStats) IsPrimaryKeySet ¶
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*HoleStats) SaveOrUpdate ¶
SaveOrUpdate saves the HoleStats to the database, but tries to update on unique constraint violations.
type LoggableDBTransactionHandler ¶
type LoggableDBTransactionHandler struct {
// contains filtered or unexported fields
}
LoggableDBTransactionHandler handles a transaction and logs any error.
func NewLoggableDBTransactionHandler ¶
func NewLoggableDBTransactionHandler(db Transactioner, l *slog.Logger) *LoggableDBTransactionHandler
NewLoggableDBTransactionHandler returns a configured instance of LoggableDBTransactionHandler
type PostDeletable ¶
type PostDeletable interface {
PostDelete() error
}
PostDeletable is the interface implemented by types which run a post delete step.
type PostSaveable ¶
type PostSaveable interface {
PostSave() error
}
PostSaveable is the interface implemented by types which run a post save step.
type PreDeletable ¶
type PreDeletable interface {
PreDelete() error
}
PreDeletable is the interface implemented by types which run a pre delete step.
type PreSaveable ¶
PreSaveable is the interface implemented by types which run a pre save step.
type Round ¶
type Round struct { Id int `db:"id,autoinc,pk"` UserId int `db:"user_id"` TeeTime time.Time `db:"tee_time"` }
Round represents a row from 'round'.
func (*Round) InsertWithUpdate ¶
InsertWithUpdate inserts the Round to the database, and tries to update on unique constraint violations.
func (*Round) IsPrimaryKeySet ¶
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*Round) SaveOrUpdate ¶
SaveOrUpdate saves the Round to the database, but tries to update on unique constraint violations.
type RoundHitStats ¶
type RoundHitStats struct { Id int `db:"id,autoinc,pk"` RoundStatsId int `db:"round_stats_id"` Type usql.Enum `db:"type"` Miss string `db:"miss"` Count int `db:"count"` }
RoundHitStats represents a row from 'round_hit_stats'.
func RoundHitStatsById ¶
func RoundHitStatsById(db DB, id int) (*RoundHitStats, error)
RoundHitStatsById retrieves a row from 'round_hit_stats' as a RoundHitStats.
Generated from primary key.
func (*RoundHitStats) Delete ¶
func (m *RoundHitStats) Delete(db DB) error
Delete deletes the RoundHitStats from the database.
func (*RoundHitStats) GetRoundStats ¶
func (m *RoundHitStats) GetRoundStats(db DB) (*RoundStats, error)
GetRoundStats Gets an instance of RoundStats
Generated from constraint round_hit_stats_round_stats_id_fk
func (*RoundHitStats) Insert ¶
func (m *RoundHitStats) Insert(db DB) error
Insert inserts the RoundHitStats to the database.
func (*RoundHitStats) InsertWithUpdate ¶
func (m *RoundHitStats) InsertWithUpdate(db DB) error
InsertWithUpdate inserts the RoundHitStats to the database, and tries to update on unique constraint violations.
func (*RoundHitStats) IsPrimaryKeySet ¶
func (m *RoundHitStats) IsPrimaryKeySet() bool
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*RoundHitStats) Save ¶
func (m *RoundHitStats) Save(db DB) error
Save saves the RoundHitStats to the database.
func (*RoundHitStats) SaveOrUpdate ¶
func (m *RoundHitStats) SaveOrUpdate(db DB) error
SaveOrUpdate saves the RoundHitStats to the database, but tries to update on unique constraint violations.
func (*RoundHitStats) Update ¶
func (m *RoundHitStats) Update(db DB) error
Update updates the RoundHitStats in the database.
type RoundStats ¶
type RoundStats struct { Id int `db:"id,autoinc,pk"` RoundId int `db:"round_id"` AvgFairwaysHit float64 `db:"avg_fairways_hit"` AvgGreensHit float64 `db:"avg_greens_hit"` AvgPutts float64 `db:"avg_putts"` Penalties int `db:"penalties"` AvgPar3 float64 `db:"avg_par_3"` AvgPar4 float64 `db:"avg_par_4"` AvgPar5 float64 `db:"avg_par_5"` }
RoundStats represents a row from 'round_stats'.
func RoundStatsById ¶
func RoundStatsById(db DB, id int) (*RoundStats, error)
RoundStatsById retrieves a row from 'round_stats' as a RoundStats.
Generated from primary key.
func (*RoundStats) Delete ¶
func (m *RoundStats) Delete(db DB) error
Delete deletes the RoundStats from the database.
func (*RoundStats) GetRound ¶
func (m *RoundStats) GetRound(db DB) (*Round, error)
GetRound Gets an instance of Round
Generated from constraint round_stats_round_id_fk
func (*RoundStats) Insert ¶
func (m *RoundStats) Insert(db DB) error
Insert inserts the RoundStats to the database.
func (*RoundStats) InsertWithUpdate ¶
func (m *RoundStats) InsertWithUpdate(db DB) error
InsertWithUpdate inserts the RoundStats to the database, and tries to update on unique constraint violations.
func (*RoundStats) IsPrimaryKeySet ¶
func (m *RoundStats) IsPrimaryKeySet() bool
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*RoundStats) Save ¶
func (m *RoundStats) Save(db DB) error
Save saves the RoundStats to the database.
func (*RoundStats) SaveOrUpdate ¶
func (m *RoundStats) SaveOrUpdate(db DB) error
SaveOrUpdate saves the RoundStats to the database, but tries to update on unique constraint violations.
func (*RoundStats) Update ¶
func (m *RoundStats) Update(db DB) error
Update updates the RoundStats in the database.
type Saveable ¶
Saveable is the interface implemented by types which can save themselves to the database.
type SetLogger ¶
SetLogger is the interface implemented by types which have the ability to configure their log entry.
type TransactionFunc ¶
TransactionFunc is a function to be called within a transaction.
type TransactionHandler ¶
type TransactionHandler interface {
Handle(TransactionFunc) error
}
type Transactioner ¶
Transactioner is the interface that a database connection that can start a transaction should implement.
type User ¶
type User struct { Id int `db:"id,autoinc,pk"` Name string `db:"name"` Username string `db:"username"` Password string `db:"password"` LastLogin usql.NullTime `db:"last_login"` }
User represents a row from 'user'.
func (*User) InsertWithUpdate ¶
InsertWithUpdate inserts the User to the database, and tries to update on unique constraint violations.
func (*User) IsPrimaryKeySet ¶
IsPrimaryKeySet returns true if all primary key fields are set to none zero values
func (*User) SaveOrUpdate ¶
SaveOrUpdate saves the User to the database, but tries to update on unique constraint violations.