aboutsummaryrefslogtreecommitdiff
path: root/internal/database/database.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 23:33:20 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 23:33:20 +0800
commitb29061d0798ad854cd0f27ce60d7c58c10a239e9 (patch)
treeb1892db8fe9b49cba1a6a48227144e0863257ae1 /internal/database/database.go
parentMove trivial template functions into misc (diff)
downloadforge-b29061d0798ad854cd0f27ce60d7c58c10a239e9.tar.gz
forge-b29061d0798ad854cd0f27ce60d7c58c10a239e9.tar.zst
forge-b29061d0798ad854cd0f27ce60d7c58c10a239e9.zip
database: Separate opening the database into its own package
Diffstat (limited to 'internal/database/database.go')
-rw-r--r--internal/database/database.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/database/database.go b/internal/database/database.go
new file mode 100644
index 0000000..27c3b38
--- /dev/null
+++ b/internal/database/database.go
@@ -0,0 +1,16 @@
+package database
+
+import (
+ "context"
+
+ "github.com/jackc/pgx/v5/pgxpool"
+)
+
+type Database struct {
+ *pgxpool.Pool
+}
+
+func Open(connString string) (Database, error) {
+ db, err := pgxpool.New(context.Background(), connString)
+ return Database{db}, err
+}