Documentation
¶
Index ¶
- Constants
- type Database
- type Service
- func (s *Service) AdaptPostgresModelToTypeLogbook(m *pgmodels.Logbook) (types.Logbook, error)
- func (s *Service) AdaptPostgresModelToTypeQso(m *pgmodels.Qso) (types.Qso, error)
- func (s *Service) AdaptPostgresModelToTypeUser(m *pgmodels.User) (types.User, error)
- func (s *Service) AdaptSqliteModelToTypeContactedStation(m *sqmodels.ContactedStation) (types.ContactedStation, error)
- func (s *Service) AdaptSqliteModelToTypeLogbook(m *sqmodels.Logbook) (types.Logbook, error)
- func (s *Service) AdaptSqliteModelToTypeQso(m *sqmodels.Qso) (types.Qso, error)
- func (s *Service) AdaptTypeToPostgresModelLogbook(lb types.Logbook) (*pgmodels.Logbook, error)
- func (s *Service) AdaptTypeToPostgresModelQso(q types.Qso) (*pgmodels.Qso, error)
- func (s *Service) AdaptTypeToPostgresModelUser(u types.User) (*pgmodels.User, error)
- func (s *Service) AdaptTypeToSqliteModelContactedStation(u types.ContactedStation) (*sqmodels.ContactedStation, error)
- func (s *Service) AdaptTypeToSqliteModelLogbook(lb types.Logbook) (*sqmodels.Logbook, error)
- func (s *Service) AdaptTypeToSqliteModelQso(q types.Qso) (*sqmodels.Qso, error)
- func (s *Service) BeginTxContext(ctx context.Context) (*sql.Tx, context.CancelFunc, error)
- func (s *Service) Close() error
- func (s *Service) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (s *Service) FetchUserByCallsign(callsign string) (types.User, error)
- func (s *Service) FetchUserByCallsignContext(ctx context.Context, callsign string) (types.User, error)
- func (s *Service) GenerateNewSessionID() (int64, error)
- func (s *Service) Initialize() error
- func (s *Service) InsertUser(user types.User) (types.User, error)
- func (s *Service) InsertUserContext(ctx context.Context, user types.User) (types.User, error)
- func (s *Service) LogStats(prefix string)
- func (s *Service) Migrate() error
- func (s *Service) Open() error
- func (s *Service) Ping() error
- func (s *Service) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (s *Service) SoftDeleteSessionID(id int64) error
- func (s *Service) UpdateUser(user types.User) error
- func (s *Service) UpdateUserContext(ctx context.Context, user types.User) error
Constants ¶
const ( ServiceName = types.DatabaseServiceName PostgresDriver = "postgres" SqliteDriver = "sqlite" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
ConfigService *config.Service `di.inject:"configservice"`
Logger *logging.Service `di.inject:"loggingservice"`
DatabaseConfig *types.DatastoreConfig
// contains filtered or unexported fields
}
func (*Service) AdaptPostgresModelToTypeLogbook ¶ added in v0.0.8
AdaptPostgresModelToTypeLogbook adapts postgres model Logbook to types.Logbook.
func (*Service) AdaptPostgresModelToTypeQso ¶ added in v0.0.8
AdaptPostgresModelToTypeQso adapts postgres model to types.Qso.
func (*Service) AdaptPostgresModelToTypeUser ¶ added in v0.0.9
func (*Service) AdaptSqliteModelToTypeContactedStation ¶ added in v0.0.15
func (s *Service) AdaptSqliteModelToTypeContactedStation(m *sqmodels.ContactedStation) (types.ContactedStation, error)
AdaptSqliteModelToTypeContactedStation converts a ContactedStation SQLite model to its corresponding domain type. Returns the converted types.ContactedStation and an error if the service or adapter is nil, or if the conversion fails.
func (*Service) AdaptSqliteModelToTypeLogbook ¶ added in v0.0.8
AdaptSqliteModelToTypeLogbook adapts sqlite model Logbook to types.Logbook.
func (*Service) AdaptSqliteModelToTypeQso ¶ added in v0.0.8
AdaptSqliteModelToTypeQso adapts sqlite model to types.Qso.
func (*Service) AdaptTypeToPostgresModelLogbook ¶ added in v0.0.8
AdaptTypeToPostgresModelLogbook adapts a types.Logbook into a postgres model Logbook.
func (*Service) AdaptTypeToPostgresModelQso ¶ added in v0.0.8
AdaptTypeToPostgresModelQso adapts a types.Qso into a postgres model Qso.
func (*Service) AdaptTypeToPostgresModelUser ¶ added in v0.0.9
func (*Service) AdaptTypeToSqliteModelContactedStation ¶ added in v0.0.20
func (s *Service) AdaptTypeToSqliteModelContactedStation(u types.ContactedStation) (*sqmodels.ContactedStation, error)
AdaptTypeToSqliteModelContactedStation converts a types.ContactedStation object to its corresponding SQLite model representation. Returns the SQLite model instance and any error encountered during the adaptation process. If the service or its adapter is nil, it returns an error indicating the issue.
func (*Service) AdaptTypeToSqliteModelLogbook ¶ added in v0.0.8
AdaptTypeToSqliteModelLogbook adapts a types.Logbook into a sqlite model Logbook.
func (*Service) AdaptTypeToSqliteModelQso ¶ added in v0.0.8
AdaptTypeToSqliteModelQso adapts a types.Qso into a sqlite model Qso.
func (*Service) BeginTxContext ¶
BeginTxContext starts a new transaction.
func (*Service) ExecContext ¶
func (*Service) FetchUserByCallsign ¶ added in v0.0.10
FetchUserByCallsign returns a user by its callsign or an empty user if no user was found.
func (*Service) FetchUserByCallsignContext ¶ added in v0.0.10
func (s *Service) FetchUserByCallsignContext(ctx context.Context, callsign string) (types.User, error)
FetchUserByCallsignContext retrieves a user by their callsign from the database with the provided context. Returns an error if the database service is uninitialized, callsign is empty, or the user is not found. Uses a default timeout if no deadline is set in the given context.
func (*Service) GenerateNewSessionID ¶ added in v0.0.19
func (*Service) Initialize ¶
Initialize initializes the database service. No constructor is provided as this service is to be initialized within an IOC/DI container.
func (*Service) InsertUser ¶ added in v0.0.9
InsertUser inserts a new user into the database and returns the inserted user or an error if any operation fails. This calls InsertUserContext with a background context.
func (*Service) InsertUserContext ¶ added in v0.0.9
InsertUserContext inserts a new user into the database and returns the inserted user or an error if any operation fails.
func (*Service) QueryContext ¶
func (*Service) SoftDeleteSessionID ¶ added in v0.0.19
func (*Service) UpdateUser ¶ added in v0.0.10
UpdateUser updates the provided user in the database using the given service instance and context.
func (*Service) UpdateUserContext ¶ added in v0.0.10
UpdateUserContext updates the database with the provided user data using a database handle and adapter for conversions. It ensures the database service is open, applies model converters, and validates context timeout before updating. Returns an error if the service is not operational, converters fail, or the update operation encounters an issue.