Documentation
¶
Index ¶
- func BuildDSN(config config.DatabaseConfig) string
- func ToNamedValues(args []driver.Value) []any
- type Connector
- type Driver
- type SQLDB
- type SQLDatabase
- func (d *SQLDatabase) Connect() error
- func (d *SQLDatabase) Count(ctx context.Context, table string, filter []port.DbExpression) (int64, error)
- func (d *SQLDatabase) Delete(ctx context.Context, table string, filter []port.DbExpression) (int64, error)
- func (d *SQLDatabase) DeleteOne(ctx context.Context, table string, filter []port.DbExpression) (int64, error)
- func (d *SQLDatabase) Disconnect() error
- func (d *SQLDatabase) Find(ctx context.Context, results any, table string, column []string, ...) 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, _ string, data any) (any, error)
- func (d *SQLDatabase) Install(args ...any) error
- func (d *SQLDatabase) Ping(ctx context.Context) error
- func (d *SQLDatabase) SetBunDB(driver driver.Connector, dialect schema.Dialect)
- func (d *SQLDatabase) Uninstall() error
- func (d *SQLDatabase) Update(ctx context.Context, _ string, filter []port.DbExpression, data any) (int64, error)
- func (d *SQLDatabase) UpdateOne(ctx context.Context, _ string, filter []port.DbExpression, 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
func ToNamedValues ¶ added in v0.1.4
toNamedValues converts driver.Value slice to any slice
Types ¶
type Connector ¶ added in v0.1.4
type Connector struct {
// contains filtered or unexported fields
}
func NewConnector ¶ added in v0.1.4
type SQLDatabase ¶
type SQLDatabase struct {
Context context.Context
Config config.DatabaseConfig
Driver driver.Connector
Dialect schema.Dialect
DB *bun.DB
}
SQLDatabase represents shared database connection using Bun ORM
func (*SQLDatabase) Connect ¶
func (d *SQLDatabase) Connect() error
Connect establishes a database connection
func (*SQLDatabase) Count ¶
func (d *SQLDatabase) Count(ctx context.Context, table string, filter []port.DbExpression) (int64, error)
Count counts records in a table with optional filtering
func (*SQLDatabase) Delete ¶
func (d *SQLDatabase) Delete(ctx context.Context, table string, filter []port.DbExpression) (int64, error)
Delete deletes records from a table with optional filtering
func (*SQLDatabase) DeleteOne ¶
func (d *SQLDatabase) DeleteOne(ctx context.Context, table string, filter []port.DbExpression) (int64, 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, results any, table string, column []string, filter []port.DbExpression, sort map[string]int, limit int64, skip int64) 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 []port.DbExpression, 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 database driver name
func (*SQLDatabase) Ping ¶
func (d *SQLDatabase) Ping(ctx context.Context) error
Ping checks if database connection is alive
func (*SQLDatabase) SetBunDB ¶ added in v0.1.4
func (d *SQLDatabase) SetBunDB(driver driver.Connector, dialect schema.Dialect)
func (*SQLDatabase) Uninstall ¶
func (d *SQLDatabase) Uninstall() error
Connect establishes a database connection