Documentation ¶
Index ¶
- func MustOpen(name string) *mongo.Database
- func Open(name string) (*mongo.Database, error)
- type Table
- func (t *Table[T, K]) Create(ctx context.Context, doc *T) (err error)
- func (t *Table[T, K]) Delete(ctx context.Context, id K) (err error)
- func (t *Table[T, K]) Fetch(ctx context.Context, filter, sorter any) (records []*T, err error)
- func (t *Table[T, K]) FetchByPage(ctx context.Context, pageIndex, pageSize int64, filter, sorter any) (records []*T, count int64, err error)
- func (t *Table[T, K]) Query(ctx context.Context, id K) (r *T, err error)
- func (t *Table[T, K]) QueryByFilter(ctx context.Context, filter any) (r *T, err error)
- func (t *Table[T, K]) Update(ctx context.Context, id K, update any) (err error)
- func (t *Table[T, K]) Upsert(ctx context.Context, id K, update any) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Table ¶
type Table[T, K any] struct { *mongo.Collection }
func (*Table[T, K]) FetchByPage ¶
func (t *Table[T, K]) FetchByPage(ctx context.Context, pageIndex, pageSize int64, filter, sorter any) (records []*T, count int64, err error)
FetchByPage returns qualified records with paging.
func (*Table[T, K]) QueryByFilter ¶
Click to show internal directories.
Click to hide internal directories.