Documentation
¶
Index ¶
- func BuildDSN(config config.DatabaseConfig) string
- type SQLDB
- type SQLDatabase
- func (d *SQLDatabase) Connect() error
- func (d *SQLDatabase) Count(ctx context.Context, table string, filter loader.DbMap) (int64, error)
- func (d *SQLDatabase) Delete(ctx context.Context, table string, filter loader.DbMap) (any, error)
- func (d *SQLDatabase) DeleteOne(ctx context.Context, table string, filter loader.DbMap) (any, error)
- func (d *SQLDatabase) Disconnect() error
- func (d *SQLDatabase) Find(ctx context.Context, table string, column []string, filter loader.DbMap, ...) ([]loader.DbMap, error)
- func (d *SQLDatabase) FindOne(ctx context.Context, result any, table string, column []string, ...) error
- func (d *SQLDatabase) GetConnection() any
- func (d *SQLDatabase) GetDriver() string
- func (d *SQLDatabase) GetName() string
- func (d *SQLDatabase) InsertOne(ctx context.Context, table string, data any) (any, error)
- func (d *SQLDatabase) Install(args ...any) error
- func (d *SQLDatabase) Ping(ctx context.Context) error
- func (d *SQLDatabase) SetDialect(dialect gorm.Dialector)
- func (d *SQLDatabase) Uninstall() error
- func (d *SQLDatabase) Update(ctx context.Context, table string, filter loader.DbMap, data any) (int64, error)
- func (d *SQLDatabase) UpdateOne(ctx context.Context, table string, filter loader.DbMap, data any) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDSN ¶
func BuildDSN(config config.DatabaseConfig) string
BuildDSN builds a database connection string from configuration
Types ¶
type SQLDatabase ¶
type SQLDatabase struct {
Context context.Context
Config config.DatabaseConfig
DB *gorm.DB
Dialect gorm.Dialector
}
SQLDatabase represents shared database connection
func (*SQLDatabase) Connect ¶
func (d *SQLDatabase) Connect() error
Connect establishes a database connection
func (*SQLDatabase) DeleteOne ¶
func (d *SQLDatabase) DeleteOne(ctx context.Context, table string, filter loader.DbMap) (any, error)
DeleteOne deletes a single record from a table
func (*SQLDatabase) Disconnect ¶
func (d *SQLDatabase) Disconnect() error
Close closes the database connection
func (*SQLDatabase) Find ¶
func (d *SQLDatabase) Find(ctx context.Context, table string, column []string, filter loader.DbMap, sort map[string]int, limit int64, skip int64) ([]loader.DbMap, error)
Find retrieves records from a table with optional filtering, sorting, and pagination
func (*SQLDatabase) FindOne ¶
func (d *SQLDatabase) FindOne(ctx context.Context, result any, table string, column []string, filter loader.DbMap, sort map[string]int) error
FindOne retrieves a single record from a table
func (*SQLDatabase) GetConnection ¶
func (d *SQLDatabase) GetConnection() any
GetConnection returns the underlying database connection
func (*SQLDatabase) GetDriver ¶
func (d *SQLDatabase) GetDriver() string
GetDriver returns the database driver name
func (*SQLDatabase) GetName ¶
func (d *SQLDatabase) GetName() string
GetName returns the database name
func (*SQLDatabase) Ping ¶
func (d *SQLDatabase) Ping(ctx context.Context) error
Ping checks if the database connection is alive
func (*SQLDatabase) SetDialect ¶
func (d *SQLDatabase) SetDialect(dialect gorm.Dialector)
func (*SQLDatabase) Uninstall ¶
func (d *SQLDatabase) Uninstall() error
Connect establishes a database connection
Click to show internal directories.
Click to hide internal directories.