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 ParseTLSConfig(pemFile []byte) (*tls.Config, error)
- 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 ClientOptions
- type Database
- func (d *Database) Close()
- func (o *Database) Count(model, filter any) (count int64, err error)
- func (o *Database) Delete(model any, id string) error
- func (o *Database) First(model, filter, sort any, projection ...any) (record M, err error)
- func (o *Database) Has(model, id any) (exists bool, err error)
- func (d *Database) Indexes(ctx context.Context, models ...any) error
- func (o *Database) List(ctx context.Context, model any, filter M, cb func(m M) (bool, error), ...) error
- func (o *Database) Pagination(model, filter, sort any, page, pageSize int64, projection ...any) (total int64, list []M, err error)
- func (o *Database) Set(record any) error
- func (d *Database) Txn(ctx context.Context, fn func(txn *Txn) error, multiDoc ...bool) error
- func (o *Database) Unmarshal(id, model any, projection ...any) error
- func (o *Database) Update(record any) (newRecord M, err error)
- 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, cb func(m M) (bool, error), projection ...any) 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 Client ¶
func NewClient ¶
func NewClient(connectionURI string, opts ...func(c *ClientOptions)) *Client
type ClientOptions ¶ added in v0.2.1
type ClientOptions options.ClientOptions
type Database ¶
func NewDatabase ¶
func NewDatabase(url string, name string, opts ...func(c *ClientOptions)) *Database
func (*Database) Pagination ¶ added in v0.2.0
func (*Database) Txn ¶
By default, MongoDB will automatically abort any multi-document transaction that runs for more than 60 seconds.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.