diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 20:26:57 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 20:26:57 +0800 |
commit | 20b4fe0c59357a433042732d46e38da9c3d14c3b (patch) | |
tree | 537d7d450701a839802b1d57a82bd07324dcba90 /database.go | |
parent | misc: Move utils.go's string function to misc (diff) | |
download | forge-20b4fe0c59357a433042732d46e38da9c3d14c3b.tar.gz forge-20b4fe0c59357a433042732d46e38da9c3d14c3b.tar.zst forge-20b4fe0c59357a433042732d46e38da9c3d14c3b.zip |
database shall no longer be a global variable
Diffstat (limited to 'database.go')
-rw-r--r-- | database.go | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/database.go b/database.go index 18e753f..1ea0753 100644 --- a/database.go +++ b/database.go @@ -7,7 +7,6 @@ import ( "context" "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/pgxpool" ) // TODO: All database handling logic in all request handlers must be revamped. @@ -16,18 +15,13 @@ import ( // at a single point. A failure to do so may cause things as serious as // privilege escalation. -// database serves as the primary database handle for this entire application. -// Transactions or single reads may be used from it. A [pgxpool.Pool] is -// necessary to safely use pgx concurrently; pgx.Conn, etc. are insufficient. -var database *pgxpool.Pool - // queryNameDesc is a helper function that executes a query and returns a // list of nameDesc results. The query must return two string arguments, i.e. a // name and a description. func (s *server) queryNameDesc(ctx context.Context, query string, args ...any) (result []nameDesc, err error) { var rows pgx.Rows - if rows, err = database.Query(ctx, query, args...); err != nil { + if rows, err = s.database.Query(ctx, query, args...); err != nil { return nil, err } defer rows.Close() |