aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-04-11 20:19:12 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-04-11 20:20:03 +0200
commite9d31443f01eda2ecee66dbc25f154a6949a9c97 (patch)
tree1824c7dc3290e4d38ab111522938e8a33e2f9618 /db.go
parent3d28ce0650fc85ca054a608bce32f88f2d90295f (diff)
downloadgo-oblast-e9d31443f01eda2ecee66dbc25f154a6949a9c97.tar.gz
reorganize the API from type DB to type Store
Diffstat (limited to 'db.go')
-rw-r--r--db.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/db.go b/db.go
deleted file mode 100644
index cdf9e1a..0000000
--- a/db.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net>
-// SPDX-License-Identifier: Apache-2.0
-
-package oblast
-
-import (
- "database/sql"
- "reflect"
- "sync"
-
- "go.xyrillian.de/oblast/internal"
-)
-
-// DB wraps an [sql.DB] instance for use with Oblast's query interface.
-type DB struct {
- *sql.DB
- dialect Dialect
- plans map[reflect.Type]internal.Plan
- planMutex sync.Mutex
-}
-
-func NewDB(db *sql.DB, dialect Dialect) *DB {
- return &DB{
- DB: db,
- dialect: dialect,
- plans: make(map[reflect.Type]internal.Plan),
- }
-}
-
-func (d *DB) getPlan(t reflect.Type) (internal.Plan, error) {
- d.planMutex.Lock()
- defer d.planMutex.Unlock()
- p, ok := d.plans[t]
- if ok {
- return p, nil
- }
- p, err := internal.BuildPlan(t, d.dialect)
- if err == nil {
- d.plans[t] = p
- }
- return p, err
-}
-
-// TODO: Begin() -> custom Tx type; add interface to allow Select() et all to take either *DB or *Tx