sql

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 3

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

Types

type SQLDB

type SQLDB interface {
	loader.IDatabase
}

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

func (d *SQLDatabase) Count(ctx context.Context, table string, filter loader.DbMap) (int64, error)

Count counts records in a table with optional filtering

func (*SQLDatabase) Delete

func (d *SQLDatabase) Delete(ctx context.Context, table string, filter loader.DbMap) (any, error)

Delete deletes records from a table with optional filtering

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

func (d *SQLDatabase) InsertOne(ctx context.Context, table 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 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

func (*SQLDatabase) Update

func (d *SQLDatabase) Update(ctx context.Context, table string, filter loader.DbMap, data any) (int64, error)

Update updates records in a table with optional filtering

func (*SQLDatabase) UpdateOne

func (d *SQLDatabase) UpdateOne(ctx context.Context, table string, filter loader.DbMap, 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