Documentation
¶
Index ¶
- func IsID[I ID](id I) bool
- func NoID[I ID]() I
- type Base
- type DBRepo
- func (r *DBRepo[E, I, P]) Create(cmd sqlize.CtxCmd, entity P) (*E, error)
- func (r *DBRepo[E, I, P]) CreateContext(ctx context.Context, cmd sqlize.CtxCmd, entity P) (*E, error)
- func (r *DBRepo[E, I, _]) Delete(cmd sqlize.CtxCmd, id I) error
- func (r *DBRepo[E, I, _]) DeleteContext(ctx context.Context, cmd sqlize.CtxCmd, id I) error
- func (r *DBRepo[E, I, P]) Read(cmd sqlize.CtxCmd, id I, reuse P) (*E, error)
- func (r *DBRepo[E, I, P]) ReadContext(ctx context.Context, cmd sqlize.CtxCmd, id I, reuse P) (*E, error)
- func (r *DBRepo[E, _, _]) Update(cmd sqlize.CtxCmd, entity *E) error
- func (r *DBRepo[E, _, _]) UpdateContext(ctx context.Context, cmd sqlize.CtxCmd, entity *E) error
- type Entity
- type ID
- type ID16
- type ID32
- type ID64
- type MapCache
- func (mc *MapCache[E, I, P]) Clear()
- func (mc *MapCache[E, I, P]) Create(cmd sqlize.CtxCmd, entity P) (*E, error)
- func (mc *MapCache[E, I, P]) CreateContext(ctx context.Context, cmd sqlize.CtxCmd, entity P) (*E, error)
- func (mc *MapCache[E, I, P]) Delete(cmd sqlize.CtxCmd, id I) error
- func (mc *MapCache[E, I, P]) DeleteContext(ctx context.Context, cmd sqlize.CtxCmd, id I) error
- func (mc *MapCache[E, I, P]) Read(cmd sqlize.CtxCmd, id I, reuse P) (*E, error)
- func (mc *MapCache[E, I, P]) ReadContext(ctx context.Context, cmd sqlize.CtxCmd, id I, reuse P) (*E, error)
- func (mc *MapCache[E, I, P]) Update(cmd sqlize.CtxCmd, entity P) error
- func (mc *MapCache[E, I, P]) UpdateContext(ctx context.Context, cmd sqlize.CtxCmd, entity P) error
- type NumID
- type PolyID
- type Reader
- type Ref
- func (ref *Ref[E, ID]) Clear()
- func (ref *Ref[E, ID]) Get(db sqlize.CtxCmd) (*E, error)
- func (ref *Ref[E, ID]) GetContext(ctx context.Context, db sqlize.CtxCmd) (entity *E, err error)
- func (ref Ref[E, ID]) ID() ID
- func (ref Ref[E, ID]) Nil() bool
- func (ref Ref[E, ID]) Resolved() (is bool, entity *E)
- func (ref *Ref[E, I]) Scanner(r Reader[E, I]) refScanner[E, I]
- func (ref *Ref[E, ID]) Set(entity *E)
- func (ref *Ref[E, ID]) SetID(r Reader[E, ID], id ID) error
- func (ref *Ref[E, ID]) SetReader(r Reader[E, ID])
- func (ref Ref[E, ID]) Value() (driver.Value, error)
- func (ref Ref[E, ID]) WithReader(r Reader[E, ID]) (res Ref[E, ID])
- type Repo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
type Base[I ID] struct { // contains filtered or unexported fields }
func (*Base[I]) EntityIDScanner ¶
type DBRepo ¶
func (*DBRepo[E, I, P]) CreateContext ¶ added in v0.9.0
func (*DBRepo[E, I, _]) DeleteContext ¶ added in v0.9.0
func (*DBRepo[E, I, P]) ReadContext ¶
type ID ¶
type ID interface {
comparable
driver.Valuer
}
Pointer to ID types must implement sql.Scanner
type ID32 ¶
type ID32 int32
Example ¶
type Dummy struct{ Base[ID32] }
var d Dummy
fmt.Println(d.FromSQLid(nil).(sql.Scanner).Scan(int64(4711)))
fmt.Println(d.ToSQLid(nil))
Output: <nil> 4711
type MapCache ¶ added in v0.9.0
type MapCache[E Entity[I], I ID, P ePtr[E, I]] struct { Repo Repo[E, I] // contains filtered or unexported fields }
MapCache is a simple write-through cache for repos that does not implement any eviction strategy. It only allows to explicitly [Clear] the cache. MapCache implements the Repo interface.
func NewMapCache ¶ added in v0.9.0
func (*MapCache[E, I, P]) CreateContext ¶ added in v0.9.0
func (*MapCache[E, I, P]) DeleteContext ¶ added in v0.9.0
func (*MapCache[E, I, P]) ReadContext ¶ added in v0.9.0
type Repo ¶
type Repo[E Entity[I], I ID] interface { Reader[E, I] Read(cmd sqlize.CtxCmd, id I, reuse *E) (*E, error) Create(cmd sqlize.CtxCmd, entity *E) (*E, error) CreateContext(ctx context.Context, cmd sqlize.CtxCmd, entity *E) (*E, error) Update(cmd sqlize.CtxCmd, entity *E) error UpdateContext(ctx context.Context, cmd sqlize.CtxCmd, entity *E) error Delete(cmd sqlize.CtxCmd, id I) error DeleteContext(ctx context.Context, cmd sqlize.CtxCmd, id I) error }
Click to show internal directories.
Click to hide internal directories.