sql

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSQLRepository

type BaseSQLRepository[T any, K comparable] struct {
	DB        *sql.DB
	TableName string
}

BaseSQLRepository provides common functionality for SQL-based repositories. It's meant to be embedded in concrete repository implementations or used as a reference. T is the entity type, K is the ID type.

func NewBaseSQLRepository

func NewBaseSQLRepository[T any, K comparable](db *sql.DB, tableName string) *BaseSQLRepository[T, K]

NewBaseSQLRepository creates a new BaseSQLRepository.

func (*BaseSQLRepository[T, K]) DeleteByID

func (r *BaseSQLRepository[T, K]) DeleteByID(ctx context.Context, id K) error

DeleteByID is a placeholder for a generic delete by ID operation.

func (*BaseSQLRepository[T, K]) ExistsByID

func (r *BaseSQLRepository[T, K]) ExistsByID(ctx context.Context, id K) (bool, error)

ExistsByID is a placeholder for a generic exists by ID operation.

func (*BaseSQLRepository[T, K]) FindAll

func (r *BaseSQLRepository[T, K]) FindAll(ctx context.Context) ([]T, error)

FindAll is a placeholder for a generic find all operation.

func (*BaseSQLRepository[T, K]) FindByID

func (r *BaseSQLRepository[T, K]) FindByID(ctx context.Context, id K) (T, error)

FindByID is a placeholder for a generic find by ID operation.

func (*BaseSQLRepository[T, K]) Save

func (r *BaseSQLRepository[T, K]) Save(ctx context.Context, entity T) (T, error)

Save is a placeholder for a generic save operation. A truly generic Save method without an ORM is highly complex and usually implemented by concrete business repositories using reflection or a SQL builder.

Jump to

Keyboard shortcuts

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