Documentation ¶
Index ¶
- func EmptyID() hexa.ID
- func HealthPing(cli *mongo.Client) hexa.Ping
- func ID(id any) hexa.ID
- func NewComposedMonitor(monitors ...*event.CommandMonitor) *event.CommandMonitor
- func NewLogMonitor(l hlog.Logger) *event.CommandMonitor
- type Entity
- type IDField
- type Store
- func (r Store) CreateIndexIfNotExist(coll *mgm.Collection, name string, keys ...any) error
- func (r *Store) CreateIndexWithOptionsIfNotExist(coll *mgm.Collection, o *options.IndexOptions, fields ...any) error
- func (r Store) CreateUniqueIndexIfNotExist(coll *mgm.Collection, name string, keys ...any) error
- func (r Store) ReplaceErr(err error, notfoundErr error) error
- type TimeTouchable
- type Touchable
- type TouchableEntity
- type VersionTouchable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewComposedMonitor ¶
func NewComposedMonitor(monitors ...*event.CommandMonitor) *event.CommandMonitor
func NewLogMonitor ¶
func NewLogMonitor(l hlog.Logger) *event.CommandMonitor
Types ¶
type Entity ¶
type Entity struct {
IDField `bson:",inline"`
}
Entity struct contain model's default fields.
type IDField ¶
IDField struct contain model's ID field. This struct implements the mgm.Model and mgmrel.Syncing interfaces.
type Store ¶
type Store struct { }
func (Store) CreateIndexIfNotExist ¶
func (*Store) CreateIndexWithOptionsIfNotExist ¶
func (r *Store) CreateIndexWithOptionsIfNotExist(coll *mgm.Collection, o *options.IndexOptions, fields ...any) error
CreateIndexWithOptionsIfNotExist creates index if it doesn't exist. fields value could be either string or bson.E. One exception is if the first field value's type is bson.D, we will use it and ignore all other fields values. otherwise if you send another type as field it will panic.
func (Store) CreateUniqueIndexIfNotExist ¶
type TimeTouchable ¶
type TimeTouchable struct { CreatedAt time.Time `json:"created_at" bson:"created_at"` UpdatedAt time.Time `json:"updated_at" bson:"updated_at"` }
func (*TimeTouchable) Touch ¶
func (t *TimeTouchable) Touch()
func (*TimeTouchable) TouchAt ¶
func (t *TimeTouchable) TouchAt(at time.Time)
TouchAt is idempotent, so you can call it multiple time.
type Touchable ¶
type Touchable struct { VersionTouchable `bson:",inline"` TimeTouchable `bson:",inline"` }
type TouchableEntity ¶
TouchableEntity struct is the entity base struct with touch feature to increase its version on each change or set date fields on each update.
type VersionTouchable ¶
type VersionTouchable struct { Version int64 `json:"v" bson:"v"` // contains filtered or unexported fields }
func (*VersionTouchable) Touch ¶
func (t *VersionTouchable) Touch()
Touch is idempotent, so you can call it multiple times.