database

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 22 Imported by: 0

README

Station Manager: database module

Postgres

This database is used by the server for the online services, whereas SQLite is used for the local database.

Development setup

cd database/postgres

sudo systemctl start docker.service

docker-compose --env-file .env up -d

docker-compose down

SQLBoiler

Your location must be the database/postgres directory.

export PSQL_PASS=[some password]

sqlboiler psql

SQLite

Documentation

Index

Constants

View Source
const (
	ServiceName    = types.DatabaseServiceName
	PostgresDriver = "postgres"
	SqliteDriver   = "sqlite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	Open() error
	Close() error
	Ping() error
	Migrate() error
	BeginTxContext(context.Context) (*sql.Tx, context.CancelFunc, error)
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
}

type Service

type Service struct {
	ConfigService *config.Service `inject:"configservice"`
	// contains filtered or unexported fields
}

func (*Service) BeginTxContext

func (s *Service) BeginTxContext(ctx context.Context) (*sql.Tx, context.CancelFunc, error)

BeginTxContext starts a new transaction.

func (*Service) Close

func (s *Service) Close() error

Close closes the database connection.

func (*Service) ExecContext

func (s *Service) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Service) Initialize

func (s *Service) Initialize() error

Initialize initializes the database service. No constructor is provided as this service is to be initialized within an IOC/DI container.

func (*Service) Migrate

func (s *Service) Migrate() error

Migrate runs the database migrations.

func (*Service) Open

func (s *Service) Open() error

Open opens the database connection.

func (*Service) Ping

func (s *Service) Ping() error

Ping pings the database connection.

func (*Service) QueryContext

func (s *Service) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Directories

Path Synopsis
examples command
example command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL