37 lines
847 B
Go
37 lines
847 B
Go
package sqlsqlite
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
_ "modernc.org/sqlite"
|
|
)
|
|
|
|
type ServiceRegistry struct {
|
|
//lint:ignore U1000 używane po zaimplementowaniu metod
|
|
db *sql.DB
|
|
}
|
|
|
|
func OpenRegistry(dbPath string) (*ServiceRegistry, error) {
|
|
db, err := sql.Open("sqlite", dbPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ServiceRegistry{db: db}, nil
|
|
}
|
|
|
|
func (r *ServiceRegistry) Close() error {
|
|
return r.db.Close()
|
|
}
|
|
|
|
func (r *ServiceRegistry) InitSchema() error {
|
|
panic("TODO: CREATE TABLE IF NOT EXISTS services (...)")
|
|
}
|
|
|
|
func (r *ServiceRegistry) Register(name, owner string) (int64, error) {
|
|
panic("TODO: parametryzowany INSERT INTO services(name, owner) VALUES(?, ?)")
|
|
}
|
|
|
|
func (r *ServiceRegistry) FindByOwner(owner string) ([]string, error) {
|
|
panic("TODO: parametryzowany SELECT name FROM services WHERE owner = ? ORDER BY name ASC")
|
|
}
|