Documentation ¶
Overview ¶
Example (IsZero) ¶
type thing struct{} var e any fmt.Println(isZero(e)) e = &thing{} fmt.Println(isZero(e)) fmt.Println(isZero(&thing{})) fmt.Println(isZero((*thing)(nil))) fmt.Println(isZero(thing{}))
Output: true false false true true
Index ¶
- Constants
- func MapIDField[E Entity[I], I ID](m *FieldMap[E], col *bsq.Column)
- func NotNoRows(err error) error
- type Base
- type DBRepo
- func (r *DBRepo[E, I]) Create(q sqlize.Querier, entity E) (E, error)
- func (r *DBRepo[E, ID]) Delete(q sqlize.Querier, id ID) error
- func (r *DBRepo[E, I]) Prepare(db *sql.DB) error
- func (r *DBRepo[E, ID]) Read(q sqlize.Querier, id ID, reuse E) (E, error)
- func (r *DBRepo[E, ID]) Update(q sqlize.Querier, entity E) error
- type Entity
- type Entity32
- type Entity64
- type FieldMap
- func (m *FieldMap[E]) Clone() *FieldMap[E]
- func (m *FieldMap[E]) FromSQL(i int) func(E) any
- func (m *FieldMap[E]) MapBoth(col *bsq.Column, tofrom func(E) any)
- func (m *FieldMap[E]) MapFrom(col *bsq.Column, from func(E) any)
- func (m *FieldMap[E]) MapTo(col *bsq.Column, to func(E) any)
- func (m *FieldMap[E]) MapToAndFrom(col *bsq.Column, toSQL, fromSQL func(E) any)
- func (m *FieldMap[E]) ToSQL(i int) func(E) any
- type ID
- type ID32
- type ID64
- type Reader
- type Ref
- func (ref *Ref[E, ID]) Get(db sqlize.Querier) (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)
- func (ref *Ref[E, ID]) SetReader(r Reader[E, ID])
- func (ref *Ref[E, ID]) SetRef(r Ref[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
- type TypeID
- type TypeTable
Examples ¶
Constants ¶
View Source
const IDSeqMax32 = 4194303 // 0x3f_ffff
View Source
const IDSeqMax64 = 281474976710655 // 0xffff_ffffffff
View Source
const IDTypeMax32 = 511 // 0x1ff
View Source
const IDTypeMax64 = 32767 // 0x7fff
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FieldMap ¶
type FieldMap[E any] struct { // contains filtered or unexported fields }
func (*FieldMap[E]) MapToAndFrom ¶
type ID32 ¶
type ID32 int32
ID32 is the 32-bit ID type.
func MustMakeID32 ¶
MustMakeID32 panics if MakeID32 returns an error.
func NoRowsNoErr32 ¶
NoRowsNoErr32 returns sqlize.NoID, nil when err is sql.ErrNoRows
type ID64 ¶
type ID64 int64
ID64 is the 64-bit ID type.
func MustMakeID64 ¶
MustMakeID64 panics if MakeID64 returns an error.
func NoRowsNoErr64 ¶
NoRowsNoErr64 returns sqlize.NoID, nil when err is sql.ErrNoRows
type Ref ¶
func (Ref[E, ID]) WithReader ¶
type TypeID ¶
type TypeID = uint16
To support ploymorphism, IDs consist of a TypeID part and a sequence part. The number of bits for both parts depend on the number of bits in the ID type. Currently only ID32 and ID64, i.e. int32 and int64, are supported ID types. A valid type id must be > 0.
Click to show internal directories.
Click to hide internal directories.