dao

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDS = "defaultDS"

Variables

This section is empty.

Functions

func NewRepository

func NewRepository[E IEntity]() do.Provider[Repository[E]]

func NewRepositoryWithDS

func NewRepositoryWithDS[E IEntity](dsName string) do.Provider[Repository[E]]

Types

type Column

type Column[E IEntity] lo.Tuple2[string, string]

func AllColumns

func AllColumns[E IEntity](ignores ...Column[E]) []Column[E]

func Columns

func Columns[E IEntity](columns ...Column[E]) []Column[E]

func (Column[E]) Between

func (exp Column[E]) Between(v1, v2 any) Where[E]

func (Column[E]) GreaterThan

func (exp Column[E]) GreaterThan(v any) Where[E]

func (Column[E]) GreaterThanEqual

func (exp Column[E]) GreaterThanEqual(v any) Where[E]

func (Column[E]) IsNull

func (exp Column[E]) IsNull(v any) Where[E]

func (Column[E]) IsTrue

func (exp Column[E]) IsTrue(v any) Where[E]

func (Column[E]) LessThan

func (column Column[E]) LessThan(v any) Where[E]

func (Column[E]) LessThanEqual

func (exp Column[E]) LessThanEqual(v any) Where[E]

func (Column[E]) Like

func (exp Column[E]) Like(v string) Where[E]

func (Column[E]) NotLike

func (exp Column[E]) NotLike(v string) Where[E]

func (Column[E]) NotNull

func (exp Column[E]) NotNull(v any) Where[E]

func (Column[E]) NotTrue

func (exp Column[E]) NotTrue(v any) Where[E]

func (Column[E]) Set

func (column Column[E]) Set(v any) Set[E]

func (Column[E]) Sql

func (column Column[E]) Sql() string

type DBX

type DBX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	Close() error
}

DBX database adapter

type Hook

type Hook func(sql string) string

type Join

type Join[E1 IEntity, E2 IEntity] lo.Tuple2[Column[E1], Column[E2]]

type MustBeStructError

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

func (MustBeStructError) Error

func (e MustBeStructError) Error() string

type Order

type Order string
const (
	ASC  Order = "ASC"
	DESC Order = "DESC"
)

type OrderBy

type OrderBy lo.Tuple2[int, Order]

type Repository

type Repository[E IEntity] interface {
	Insert(entity E) (int64, error)
	BatchInsert(entities []E) (int64, error)
	Delete(key any) (int64, error)
	Update(set []Set[E], where Where[E]) (int64, error)
	Find(key any) (E, error)
	FindBy(where Where[E]) (E, error)
	DeleteBy(where Where[E]) (int64, error)
	Select(columns []Column[E], where Where[E], orders ...OrderBy) ([]E, error)
	Join(joins []Join[E, IEntity]) SqlBuilder[E]
	LeftJoin(joins []Join[E, IEntity]) SqlBuilder[E]
}

type Set

type Set[E IEntity] struct {
	// contains filtered or unexported fields
}

type SqlBuilder

type SqlBuilder[E IEntity] struct {
	// contains filtered or unexported fields
}

func (SqlBuilder[E]) Join

func (builder SqlBuilder[E]) Join(joins Join[IEntity, IEntity]) SqlBuilder[E]

func (SqlBuilder[E]) LeftJoin

func (builder SqlBuilder[E]) LeftJoin(joins Join[IEntity, IEntity]) SqlBuilder[E]

func (SqlBuilder[E]) Select

func (builder SqlBuilder[E]) Select(cols []Column[IEntity], where Where[IEntity], orders ...OrderBy) (*sql.Row, error)

func (SqlBuilder[E]) Update

func (builder SqlBuilder[E]) Update(sets []Set[E], where Where[IEntity]) (int64, error)

type Where

type Where[E IEntity] struct {
	// contains filtered or unexported fields
}

func And

func And[E IEntity](l Where[E], r Where[E]) Where[E]

func None

func None[E IEntity]() Where[E]

func Or

func Or[E IEntity](l Where[E], r Where[E]) Where[E]

Jump to

Keyboard shortcuts

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