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) ContactedStationExistsByCallsign(callsign string) (bool, error)
- func (s *Service) DeleteQso(id int64) error
- func (s *Service) DeleteQsoContext(ctx context.Context, id int64) error
- func (s *Service) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (s *Service) FetchAPIKeyByPrefix(prefix string) (types.ApiKey, error)
- func (s *Service) FetchAPIKeyByPrefixContext(ctx context.Context, prefix string) (types.ApiKey, error)
- func (s *Service) FetchContactedStationByCallsign(callsign string) (types.ContactedStation, error)
- func (s *Service) FetchContactedStationByCallsignContext(ctx context.Context, callsign string) (types.ContactedStation, error)
- func (s *Service) FetchContactedStationById(id int64) (types.ContactedStation, error)
- func (s *Service) FetchContactedStationByIdContext(ctx context.Context, id int64) (types.ContactedStation, error)
- func (s *Service) FetchLogbookByID(id int64) (types.Logbook, error)
- func (s *Service) FetchLogbookByIDContext(ctx context.Context, id int64) (types.Logbook, error)
- func (s *Service) FetchQsoById(id int64) (types.Qso, error)
- func (s *Service) FetchQsoByIdContext(ctx context.Context, id int64) (types.Qso, 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) InsertAPIKey(name, prefix, hash string, logbookID int64) error
- func (s *Service) InsertAPIKeyContext(ctx context.Context, name, prefix, hash string, logbookID int64) error
- func (s *Service) InsertAPIKeyWithTxContext(ctx context.Context, tx boil.ContextExecutor, name, prefix, hash string, ...) error
- func (s *Service) InsertContactedStation(station types.ContactedStation) (types.ContactedStation, error)
- func (s *Service) InsertContactedStationContext(ctx context.Context, station types.ContactedStation) (types.ContactedStation, error)
- func (s *Service) InsertLogbook(logbook types.Logbook) (types.Logbook, error)
- func (s *Service) InsertLogbookContext(ctx context.Context, logbook types.Logbook) (types.Logbook, error)
- func (s *Service) InsertLogbookWithTxContext(ctx context.Context, tx boil.ContextExecutor, logbook types.Logbook) (types.Logbook, error)
- func (s *Service) InsertQso(qso types.Qso) (types.Qso, error)
- func (s *Service) InsertQsoContext(ctx context.Context, qso types.Qso) (types.Qso, 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) UpdateContactedStation(station types.ContactedStation) error
- func (s *Service) UpdateContactedStationContext(ctx context.Context, station types.ContactedStation) error
- func (s *Service) UpdateQso(qso types.Qso) error
- func (s *Service) UpdateQsoContext(ctx context.Context, qso types.Qso) 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) ContactedStationExistsByCallsign ¶ added in v0.0.20
ContactedStationExistsByCallsign checks if a contacted station exists in the database using the provided callsign. Returns true if the station exists, false otherwise. Errors are returned for invalid input or unsupported drivers. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) DeleteQso ¶ added in v0.0.8
DeleteQso delegates to DeleteQsoContext with a background context.
func (*Service) DeleteQsoContext ¶ added in v0.0.8
DeleteQsoContext deletes a QSO with a caller-provided context.
func (*Service) ExecContext ¶
func (*Service) FetchAPIKeyByPrefix ¶ added in v0.0.10
FetchAPIKeyByPrefix retrieves an API key from the database by matching the given prefix. Returns the corresponding ApiKey and an error if the operation fails.
func (*Service) FetchAPIKeyByPrefixContext ¶ added in v0.0.10
func (s *Service) FetchAPIKeyByPrefixContext(ctx context.Context, prefix string) (types.ApiKey, error)
FetchAPIKeyByPrefixContext retrieves an API key matching the specified prefix within the provided context. Returns types.ApiKey if found or an error if not found or if an issue occurs during execution.
func (*Service) FetchContactedStationByCallsign ¶ added in v0.0.15
func (s *Service) FetchContactedStationByCallsign(callsign string) (types.ContactedStation, error)
FetchContactedStationByCallsign retrieves a contacted station's details using the provided callsign. It returns a ContactedStation object or an error if the fetch operation fails. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) FetchContactedStationByCallsignContext ¶ added in v0.0.15
func (s *Service) FetchContactedStationByCallsignContext(ctx context.Context, callsign string) (types.ContactedStation, error)
FetchContactedStationByCallsignContext retrieves a contacted station's details by callsign within a given context. Returns a ContactedStation object or an error if the retrieval fails or the database driver is unsupported. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) FetchContactedStationById ¶ added in v0.0.15
func (s *Service) FetchContactedStationById(id int64) (types.ContactedStation, error)
FetchContactedStationById retrieves a contacted station's details by its unique identifier from persistent storage. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) FetchContactedStationByIdContext ¶ added in v0.0.15
func (s *Service) FetchContactedStationByIdContext(ctx context.Context, id int64) (types.ContactedStation, error)
FetchContactedStationByIdContext retrieves a contacted station by ID within the given context, implementing driver-specific logic. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) FetchLogbookByID ¶ added in v0.0.10
FetchLogbookByID retrieves a logbook by its ID from the database and returns it along with possible errors.
func (*Service) FetchLogbookByIDContext ¶ added in v0.0.10
FetchLogbookByIDContext retrieves a logbook by its ID within the provided context from the configured database.
func (*Service) FetchQsoById ¶ added in v0.0.7
FetchQsoById retrieves a QSO record by its unique ID and returns it, defaulting to the background context for execution.
func (*Service) FetchQsoByIdContext ¶ added in v0.0.8
FetchQsoByIdContext fetches a QSO record by its unique ID within the provided context and returns it or an error.
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) InsertAPIKey ¶ added in v0.0.10
InsertAPIKey inserts a new API key into the database with the given name, prefix, hash, and associated logbook ID. Returns an error if the service is uninitialized, not open, or if insertion fails.
func (*Service) InsertAPIKeyContext ¶ added in v0.0.10
func (s *Service) InsertAPIKeyContext(ctx context.Context, name, prefix, hash string, logbookID int64) error
InsertAPIKeyContext inserts a new API key into the database with the given name, prefix, hash, and associated logbook ID. Returns an error if insertion fails.
func (*Service) InsertAPIKeyWithTxContext ¶ added in v0.0.10
func (s *Service) InsertAPIKeyWithTxContext(ctx context.Context, tx boil.ContextExecutor, name, prefix, hash string, logbookID int64) error
InsertAPIKeyWithTxContext inserts the API key using the provided transaction and context. It mirrors InsertAPIKeyContext but uses the given ContextExecutor instead of the shared handle so callers can coordinate it with other changes in a single atomic transaction.
func (*Service) InsertContactedStation ¶ added in v0.0.15
func (s *Service) InsertContactedStation(station types.ContactedStation) (types.ContactedStation, error)
InsertContactedStation inserts a contacted station record into the datastore using the provided station details. It returns the inserted types.ContactedStation object or an error if the operation fails. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) InsertContactedStationContext ¶ added in v0.0.15
func (s *Service) InsertContactedStationContext(ctx context.Context, station types.ContactedStation) (types.ContactedStation, error)
InsertContactedStationContext inserts a contacted station record into the database in a specific context. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) InsertLogbook ¶ added in v0.0.8
InsertLogbook creates and stores a new logbook entry in the database, returning the created logbook or an error.
func (*Service) InsertLogbookContext ¶ added in v0.0.8
func (s *Service) InsertLogbookContext(ctx context.Context, logbook types.Logbook) (types.Logbook, error)
InsertLogbookContext inserts a new logbook into the database within the provided context and returns the created logbook or an error.
func (*Service) InsertLogbookWithTxContext ¶ added in v0.0.10
func (s *Service) InsertLogbookWithTxContext(ctx context.Context, tx boil.ContextExecutor, logbook types.Logbook) (types.Logbook, error)
InsertLogbookWithTxContext performs a logbook insert using the provided transaction and context. This is used by higher-level operations that need to coordinate multiple writes atomically.
func (*Service) InsertQso ¶ added in v0.0.7
InsertQso inserts a QSO using a background context with default timeout semantics.
func (*Service) InsertQsoContext ¶ added in v0.0.8
InsertQsoContext inserts a QSO with caller-provided context. If the context has no deadline, a default timeout is applied.
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) UpdateContactedStation ¶ added in v0.0.21
func (s *Service) UpdateContactedStation(station types.ContactedStation) error
UpdateContactedStation updates the contacted station details in the database using a default background context. It ensures the provided contacted station data is valid and triggers an update operation. Returns an error if the update fails. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) UpdateContactedStationContext ¶ added in v0.0.21
func (s *Service) UpdateContactedStationContext(ctx context.Context, station types.ContactedStation) error
UpdateContactedStationContext updates the contacted station details in the database within the provided context. Returns an error if the service is nil, not initialized, not open, or if the database driver is unsupported. It supports only SQLite and will return an error for unsupported database drivers or uninitialized services.
func (*Service) UpdateQso ¶ added in v0.0.8
UpdateQso delegates to UpdateQsoContext with a background context.
func (*Service) UpdateQsoContext ¶ added in v0.0.8
UpdateQsoContext updates an existing QSO with caller-provided context.
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.