summaryrefslogtreecommitdiff
path: root/internal/storage/db.go
blob: 06fe31cc3586dcfb8020d380c837dcf107a72159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package storage

import (
	"context"
	"database/sql"
	"log/slog"

	"github.com/ChausseBenjamin/rafta/internal/util"
)

func GetDB(ctx context.Context) *sql.DB {
	db, ok := ctx.Value(util.DBKey).(*sql.DB)
	if !ok {
		slog.Error("Unable to retrieve database from context")
		return nil
	}
	return db
}