dbx

package
v0.0.0-...-b69c308 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

Storage repository

Documentation

Overview

Package database provides the database interface.

Index

Constants

View Source
const (
	FieldID        = "id"
	FieldCreatedAt = "created_at"
	FieldUpdatedAt = "updated_at"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnM

type ColumnM map[string]ColumnType

type ColumnType

type ColumnType string

type Database

type Database[T any] interface {
	Executor[T]
	Insert(ctx context.Context, builder query.Query) (string, error)
	Select(ctx context.Context, builder query.Query, scan ScanOneFn[T]) (*T, error)
	Delete(ctx context.Context, id string) error

	Total(ctx context.Context) (int64, error)

	Table() string
}

nolint:lll

type ExecResult

type ExecResult interface {
	RowsAffected() int64
}

type Executor

type Executor[T any] interface {
	Exec(ctx context.Context, builder query.Query) (ExecResult, error)
	Query(ctx context.Context, builder query.Query, dest ...any) error
	CollectRows(ctx context.Context, builder query.Query, scan ScanFn[T]) ([]*T, error)
	CollectOneRow(ctx context.Context, builder query.Query, scan ScanOneFn[T]) (*T, error)
}

nolint:lll

type Option

type Option func(*Table)

func WithColumns

func WithColumns(m ColumnM) Option

func WithTable

func WithTable(name string) Option

type Row

type Row interface {
	Scan(dest ...any) error
}

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Err() error
}

type ScanFn

type ScanFn[T any] func(Rows) ([]*T, error)

type ScanOneFn

type ScanOneFn[T any] func(Row) (*T, error)

type Table

type Table struct {
	Column ColumnM
	Table  string
}

type TxSession

type TxSession interface {
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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