Documentation ¶
Index ¶
- Constants
- Variables
- func GetID(model any) any
- func GetIdFilter(id any) any
- func GetModelName(model any) string
- func NewModelType(model any) any
- func ParseModelIndex(model any) (modelName string, indexes map[string]bool)
- func ParseTag(tag string) map[string]string
- func Pointer[T any](v T) *T
- func RandInRange(minInclusive, maxExclusive int) int
- func SequentialID() string
- func ToEntities[T any](items []M) []*T
- func ToEntity[T any](m M) *T
- func ToSnake(text string) string
- type Client
- type Database
- type M
- type Model
- func (m *Model) Count(filter any) (count int64, err error)
- func (m *Model) Del(id any) error
- func (m *Model) First(filter, sort any, projection ...any) (M, error)
- func (m *Model) Get(id any, projection ...any) (M, error)
- func (m *Model) Has(id any) (bool, error)
- func (m *Model) Inc(id, fields any) error
- func (m *Model) List(filter M, size int64, cb func(m M, total int64) (bool, error), ...) error
- func (m *Model) Next(filter, sort M, lastID string, pageSize int64, projection ...any) (list []M, err error)
- func (m *Model) Pagination(filter, sort any, page, pageSize int64, projection ...any) (total int64, list []M, err error)
- func (m *Model) Set(model any) error
- func (m *Model) Unmarshal(id, model any, projection ...any) error
- func (m *Model) Update(update any) (newRecord M, err error)
- type Txn
Constants ¶
View Source
const Tag = "db"
Variables ¶
Functions ¶
func GetIdFilter ¶
func GetModelName ¶
func NewModelType ¶
func RandInRange ¶ added in v0.0.4
RandInRange returns a random positive integer from an inclusive minimum to an exclusive maximum
func SequentialID ¶ added in v0.0.4
func SequentialID() string
func ToEntities ¶
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) List ¶
func (m *Model) List(filter M, size int64, cb func(m M, total int64) (bool, error), projection ...any) error
`cb` return `false` will stop iterate
func (*Model) Pagination ¶
Click to show internal directories.
Click to hide internal directories.