ex

package
v0.0.0-...-0a9b489 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllRecords

func AllRecords[ID comparable, Record any](set Set[ID, Record]) iter.Seq[*Record]

func FirstRecords

func FirstRecords[ID comparable, Record any](set Set[ID, Record]) iter.Seq[*Record]

Types

type Adder

type Adder[M sqlpipe.Model] interface {
	Add(m *M)
}

type Executor

type Executor[M sqlpipe.Model] struct {
	// contains filtered or unexported fields
}

func (*Executor[M]) ApplyStmt

func (e *Executor[M]) ApplyStmt(ctx context.Context, s *internal.Builder[M]) *internal.Builder[M]

ApplyStmt for Builder

func (*Executor[M]) Commit

func (e *Executor[M]) Commit(ctx context.Context) error

Commit execute sql

func (*Executor[M]) CountTo

func (e *Executor[M]) CountTo(ctx context.Context, x *int64) error

CountTo execute sql for count and marshal value into int64 ptr

func (*Executor[M]) FindOne

func (e *Executor[M]) FindOne(ctx context.Context) (*M, error)

FindOne execute then scan as Model or error notice this will return nil when not result found

func (*Executor[M]) Frag

func (e *Executor[M]) Frag(ctx context.Context) iter.Seq2[string, []any]

Frag for sql building

func (*Executor[M]) From

func (e *Executor[M]) From(src sqlpipe.Source[M]) SourceExecutor[M]

From to load data source other source for inserting

func (*Executor[M]) IsNil

func (e *Executor[M]) IsNil() bool

IsNil if true will omit in sql building

func (*Executor[M]) Item

func (e *Executor[M]) Item(ctx context.Context) iter.Seq2[*M, error]

Item Deprecated use Items instead

func (*Executor[M]) Items

func (e *Executor[M]) Items(ctx context.Context) iter.Seq2[*M, error]

Items execute sql and returns Model or error as iter.Seq

func (*Executor[M]) List

func (e *Executor[M]) List(ctx context.Context) ([]*M, error)

List execute sql and return Model slice

func (*Executor[M]) ListTo

func (e *Executor[M]) ListTo(ctx context.Context, listAdder Adder[M]) error

ListTo execute sql and return add Model into some Adder

func (*Executor[M]) Pipe

func (e *Executor[M]) Pipe(operators ...sqlpipe.SourceOperator[M]) sqlpipe.Source[M]

Pipe compose operators as Source

func (*Executor[M]) PipeE

func (e *Executor[M]) PipeE(operators ...sqlpipe.SourceOperator[M]) SourceExecutor[M]

PipeE compose operators as SourceExecutor

func (*Executor[M]) Range

func (e *Executor[M]) Range(ctx context.Context, fn func(m *M)) error

Range Deprecated use Items instead

func (*Executor[M]) Tx

func (e *Executor[M]) Tx(ctx context.Context, do func(ctx context.Context) error) error

Tx begin transaction if not in some transaction

type OneToMulti

type OneToMulti[ID comparable, Record any] map[ID][]*Record

func (OneToMulti[ID, Record]) AllRecords

func (m OneToMulti[ID, Record]) AllRecords() iter.Seq[*Record]

func (OneToMulti[ID, Record]) FillWith

func (m OneToMulti[ID, Record]) FillWith(id ID, do func(p *Record))

FillWith Deprecated use Records instead

func (OneToMulti[ID, Record]) IsZero

func (m OneToMulti[ID, Record]) IsZero() bool

func (OneToMulti[ID, Record]) Keys

func (m OneToMulti[ID, Record]) Keys() iter.Seq[ID]

func (OneToMulti[ID, Record]) Record

func (m OneToMulti[ID, Record]) Record(id ID, r *Record)

func (OneToMulti[ID, Record]) Records

func (m OneToMulti[ID, Record]) Records(id ID) iter.Seq[*Record]

type OneToOne

type OneToOne[ID comparable, Record any] map[ID]*Record

func (OneToOne[ID, Record]) AllRecords

func (m OneToOne[ID, Record]) AllRecords() iter.Seq[*Record]

AllRecords Deprecated use AllRecords instead

func (OneToOne[ID, Record]) FillWith

func (m OneToOne[ID, Record]) FillWith(id ID, do func(p *Record))

FillWith Deprecated use Records instead

func (OneToOne[ID, Record]) IsZero

func (m OneToOne[ID, Record]) IsZero() bool

func (OneToOne[ID, Record]) Keys

func (m OneToOne[ID, Record]) Keys() iter.Seq[ID]

func (OneToOne[ID, Record]) Record

func (m OneToOne[ID, Record]) Record(id ID, r *Record)

func (OneToOne[ID, Record]) Records

func (m OneToOne[ID, Record]) Records(id ID) iter.Seq[*Record]

type RelCache

type RelCache[ID comparable, Record any] = Set[ID, Record]

RelCache Deprecated use Set instead

type Set

type Set[ID comparable, Record any] interface {
	Record(id ID, r *Record)

	IsZero() bool
	Keys() iter.Seq[ID]
	Records(id ID) iter.Seq[*Record]
}

type SourceExecutor

type SourceExecutor[M sqlpipe.Model] interface {
	sqlpipe.Source[M]

	// From to load data source other source for inserting
	From(source sqlpipe.Source[M]) SourceExecutor[M]
	// PipeE compose operators as SourceExecutor
	PipeE(operators ...sqlpipe.SourceOperator[M]) SourceExecutor[M]
	// Commit just execute
	Commit(ctx context.Context) error

	// Items execute and return Model or error
	Items(ctx context.Context) iter.Seq2[*M, error]
	// FindOne execute then scan as Model or error
	// notice this will return nil when not result found
	FindOne(ctx context.Context) (*M, error)
	// List execute then list as item list
	List(ctx context.Context) ([]*M, error)
	// ListTo execute then list to item adder
	ListTo(ctx context.Context, adder Adder[M]) error
	// CountTo execute as count
	CountTo(ctx context.Context, x *int64) error

	// Item
	// Deprecated use Items instead
	Item(ctx context.Context) iter.Seq2[*M, error]
	// Range execute then range
	// Deprecated use Items instead
	Range(ctx context.Context, fn func(*M)) error
}

func FromSource

func FromSource[M sqlpipe.Model](src sqlpipe.Source[M]) SourceExecutor[M]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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