Documentation
¶
Index ¶
- Variables
- func Cursor[E Entity](db *DynamicDB, ent E, query string, args ...any) *cursor[E]
- func DataDir() string
- type Collection
- func (c *Collection[E]) Count() (count int)
- func (c *Collection[E]) Delete(ent E) error
- func (c *Collection[E]) Find(query string, args ...any) (E, error)
- func (c *Collection[E]) Get(id string) (E, error)
- func (c *Collection[E]) Index(columns ...string) error
- func (c *Collection[E]) Insert(ent E) (E, error)
- func (c *Collection[E]) New() E
- func (c *Collection[E]) Search(query string, args ...any) ([]E, error)
- func (c *Collection[E]) UniqueIndex(columns ...string) error
- func (c *Collection[E]) Update(ent E) error
- type Database
- type DynamicDB
- func (db *DynamicDB) Delete(ent Entity) error
- func (db *DynamicDB) Fields(ent Entity) (fields []string, types []string, defaults []string)
- func (db *DynamicDB) Get(id string, ent Entity) error
- func (db *DynamicDB) Index(table string, columns ...string) error
- func (db *DynamicDB) Insert(ent Entity) error
- func (db *DynamicDB) Model() Model
- func (db *DynamicDB) NewModel(id string) Model
- func (db *DynamicDB) Reflect(ent Entity) (fields []string, values []any, addrs []any)
- func (db *DynamicDB) Register(ent Entity) error
- func (db *DynamicDB) UniqueIndex(table string, columns ...string) error
- func (db *DynamicDB) Update(ent Entity) error
- type DynamicDBOption
- type Entity
- type Iter
- type Model
- type ScanFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrIterStop = fmt.Errorf("stop iteration")
)
Functions ¶
Types ¶
type Collection ¶
func Manage ¶
func Manage[E Entity](db *DynamicDB, ent E) *Collection[E]
func (*Collection[E]) Count ¶
func (c *Collection[E]) Count() (count int)
func (*Collection[E]) Delete ¶
func (c *Collection[E]) Delete(ent E) error
func (*Collection[E]) Get ¶
func (c *Collection[E]) Get(id string) (E, error)
func (*Collection[E]) Index ¶ added in v1.3.0
func (c *Collection[E]) Index(columns ...string) error
Index creates an index on the collection's table Example: Repositories.Index("UserID", "Visibility")
func (*Collection[E]) Insert ¶
func (c *Collection[E]) Insert(ent E) (E, error)
func (*Collection[E]) New ¶
func (c *Collection[E]) New() E
func (*Collection[E]) Search ¶
func (c *Collection[E]) Search(query string, args ...any) ([]E, error)
func (*Collection[E]) UniqueIndex ¶ added in v1.3.0
func (c *Collection[E]) UniqueIndex(columns ...string) error
UniqueIndex creates a unique index on the collection's table Example: Permissions.UniqueIndex("RepoID", "UserID")
func (*Collection[E]) Update ¶
func (c *Collection[E]) Update(ent E) error
type DynamicDB ¶
type DynamicDB struct {
Database
Ents []Entity
Repos map[string]*Collection[Entity]
}
func Dynamic ¶
func Dynamic(engine Database, opts ...DynamicDBOption) *DynamicDB
func (*DynamicDB) Index ¶ added in v1.3.0
Index creates an index on the specified table and columns Example: db.Index("users", "email") creates idx_users_email
func (*DynamicDB) UniqueIndex ¶ added in v1.3.0
UniqueIndex creates a unique index on the specified table and columns Example: db.UniqueIndex("users", "email") creates uniq_users_email
type DynamicDBOption ¶
type DynamicDBOption func(*DynamicDB)
func WithModel ¶
func WithModel(ent Entity) DynamicDBOption
Click to show internal directories.
Click to hide internal directories.