mirror of
https://github.com/cf-sonr/motr.git
synced 2026-01-12 02:59:13 +00:00
* feat: enhance modularity by relocating core packages * refactor: move chart components to dashboard package * refactor: restructure database access layer * refactor: rename credential descriptor to credentials for clarity * feat: enhance development environment configuration for database interactions * feat: integrate go-task for database migrations * feat: introduce middleware for market data and WebAuthn
51 lines
899 B
Go
51 lines
899 B
Go
//go:build js && wasm
|
|
// +build js,wasm
|
|
|
|
package database
|
|
|
|
import (
|
|
"github.com/sonr-io/motr/internal/db/activity"
|
|
"github.com/sonr-io/motr/internal/db/network"
|
|
"github.com/sonr-io/motr/internal/db/users"
|
|
)
|
|
|
|
// connection is a database context
|
|
type Connection interface {
|
|
IsReady() bool
|
|
Activity() activity.Querier
|
|
Network() network.Querier
|
|
Users() users.Querier
|
|
}
|
|
|
|
type connection struct {
|
|
activity activity.Querier
|
|
network network.Querier
|
|
users users.Querier
|
|
ready bool
|
|
}
|
|
|
|
func (q *connection) IsReady() bool {
|
|
return q.ready
|
|
}
|
|
|
|
func (q *connection) Activity() activity.Querier {
|
|
return q.activity
|
|
}
|
|
|
|
func (q *connection) Network() network.Querier {
|
|
return q.network
|
|
}
|
|
|
|
func (q *connection) Users() users.Querier {
|
|
return q.users
|
|
}
|
|
|
|
// Open creates a new database connection
|
|
func Open() Connection {
|
|
conn := &connection{
|
|
ready: false,
|
|
}
|
|
conn.initialize()
|
|
return conn
|
|
}
|