sql

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func ToNamedValues(args []driver.Value) []any

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

func NewConnector(name string, driver driver.Connector) *Connector

func (*Connector) Connect added in v0.1.4

func (c *Connector) Connect(ctx context.Context) (driver.Conn, error)

func (*Connector) Driver added in v0.1.4

func (c *Connector) Driver() driver.Driver

type Driver added in v0.1.4

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver added in v0.1.4

func NewDriver() Driver

func (Driver) Open added in v0.1.4

func (d Driver) Open(name string) (driver.Conn, error)

func (Driver) OpenConnector added in v0.1.4

func (d Driver) OpenConnector(name string) (driver.Connector, error)

type SQLDB

type SQLDB interface {
	port.IDatabase
}

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) GetName

func (d *SQLDatabase) GetName() string

GetName returns database name

func (*SQLDatabase) InsertOne

func (d *SQLDatabase) InsertOne(ctx context.Context, _ string, data any) (any, error)

InsertOne inserts a single record into a table

func (*SQLDatabase) Install

func (d *SQLDatabase) Install(args ...any) error

Install library

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

func (*SQLDatabase) Update

func (d *SQLDatabase) Update(ctx context.Context, _ string, filter []port.DbExpression, data any) (int64, error)

Update updates records in a table with optional filtering

func (*SQLDatabase) UpdateOne

func (d *SQLDatabase) UpdateOne(ctx context.Context, _ string, filter []port.DbExpression, data any) (int64, error)

UpdateOne updates a single record in a table

Jump to

Keyboard shortcuts

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