Documentation
¶
Overview ¶
Package database provides database interactions using sqlx.
Index ¶
- type Config
- type DB
- func (db *DB) AddServer(name, url string) (int64, error)
- func (db *DB) Close() error
- func (db *DB) GetServerByID(id int64) (*models.MCPServer, error)
- func (db *DB) GetServerByURL(url string) (*models.MCPServer, error)
- func (db *DB) ListServers() ([]models.MCPServer, error)
- func (db *DB) ListTools() ([]models.Tool, error)
- func (db *DB) ListToolsByServerID(serverID int64) ([]models.Tool, error)
- func (db *DB) RemoveServer(id int64) error
- func (db *DB) RemoveToolsByServerID(serverID int64) error
- func (db *DB) UpdateServerDetails(id int64, name, url string) error
- func (db *DB) UpdateServerStatus(id int64, state models.ConnectionState, lastError *string, lastCheck time.Time) error
- func (db *DB) UpsertTool(tool models.Tool) (err error)
- type DBInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Path string // Database file path
}
Config holds database configuration options
type DB ¶
DB holds the database connection pool using sqlx.
func (*DB) GetServerByID ¶
GetServerByID retrieves a server by its ID.
func (*DB) GetServerByURL ¶
GetServerByURL retrieves a server by its URL.
func (*DB) ListServers ¶
ListServers retrieves all servers.
func (*DB) ListToolsByServerID ¶
ListToolsByServerID retrieves all tools for a specific server.
func (*DB) RemoveServer ¶
RemoveServer deletes a server by its ID.
func (*DB) RemoveToolsByServerID ¶
RemoveToolsByServerID deletes all tools associated with a specific server ID.
func (*DB) UpdateServerDetails ¶
UpdateServerDetails updates the name and URL for a server.
func (*DB) UpdateServerStatus ¶
func (db *DB) UpdateServerStatus(id int64, state models.ConnectionState, lastError *string, lastCheck time.Time) error
UpdateServerStatus updates the connection state, error message, and last checked timestamp for a server.
type DBInterface ¶
type DBInterface interface {
// Server Management
AddServer(name, url string) (int64, error)
ListServers() ([]models.MCPServer, error)
GetServerByID(id int64) (*models.MCPServer, error)
GetServerByURL(url string) (*models.MCPServer, error)
RemoveServer(id int64) error
UpdateServerStatus(id int64, state models.ConnectionState, lastError *string, lastCheck time.Time) error
UpdateServerDetails(id int64, name, url string) error
// Tool Management
UpsertTool(tool models.Tool) error
ListTools() ([]models.Tool, error)
ListToolsByServerID(serverID int64) ([]models.Tool, error)
RemoveToolsByServerID(serverID int64) error
// General
Close() error
}
DBInterface defines the operations for interacting with the database.