Versions in this module Expand all Collapse all v2 v2.0.0 Feb 21, 2020 Changes in this version + var Version = "2.0.0" + func CollName(m Model) string + func Ctx() context.Context + func NewClient(opts ...*options.ClientOptions) (*mongo.Client, error) + func NewCtx(timeout time.Duration) context.Context + func ResetDefaultConfig() + func SetDefaultConfig(conf *Config, dbName string, opts ...*options.ClientOptions) (err error) + func Transaction(f TransactionFunc) error + func TransactionWithClient(ctx context.Context, client *mongo.Client, f TransactionFunc) error + func TransactionWithCtx(ctx context.Context, f TransactionFunc) error + type Collection struct + func Coll(m Model) *Collection + func CollectionByName(name string, opts ...*options.CollectionOptions) *Collection + func NewCollection(db *mongo.Database, name string, opts ...*options.CollectionOptions) *Collection + func (coll *Collection) Create(model Model, opts ...*options.InsertOneOptions) error + func (coll *Collection) CreateWithCtx(ctx context.Context, model Model, opts ...*options.InsertOneOptions) error + func (coll *Collection) Delete(model Model) error + func (coll *Collection) DeleteWithCtx(ctx context.Context, model Model) error + func (coll *Collection) FindByID(id interface{}, model Model) error + func (coll *Collection) FindByIDWithCtx(ctx context.Context, id interface{}, model Model) error + func (coll *Collection) First(filter interface{}, model Model, opts ...*options.FindOneOptions) error + func (coll *Collection) FirstWithCtx(ctx context.Context, filter interface{}, model Model, ...) error + func (coll *Collection) SimpleAggregate(results interface{}, stages ...interface{}) error + func (coll *Collection) SimpleAggregateCursor(stages ...interface{}) (*mongo.Cursor, error) + func (coll *Collection) SimpleFind(results interface{}, filter interface{}, opts ...*options.FindOptions) error + func (coll *Collection) SimpleFindWithCtx(ctx context.Context, results interface{}, filter interface{}, ...) error + func (coll *Collection) Update(model Model, opts ...*options.UpdateOptions) error + func (coll *Collection) UpdateWithCtx(ctx context.Context, model Model, opts ...*options.UpdateOptions) error + type CollectionGetter interface + Collection func() *Collection + type CollectionNameGetter interface + CollectionName func() string + type Config struct + CtxTimeout time.Duration + func DefaultConfigs() (*Config, *mongo.Client, *mongo.Database, error) + type CreatedHook interface + Created func() error + type CreatingHook interface + Creating func() error + type DateFields struct + CreatedAt time.Time + UpdatedAt time.Time + func (f *DateFields) Creating() error + func (f *DateFields) Saving() error + type DefaultModel struct + func (model *DefaultModel) Creating() error + func (model *DefaultModel) Saving() error + type DeletedHook interface + Deleted func(result *mongo.DeleteResult) error + type DeletingHook interface + Deleting func() error + type IDField struct + ID primitive.ObjectID + func (f *IDField) GetID() interface{} + func (f *IDField) PrepareID(id interface{}) (interface{}, error) + func (f *IDField) SetID(id interface{}) + type Model interface + GetID func() interface{} + PrepareID func(id interface{}) (interface{}, error) + SetID func(id interface{}) + type SavedHook interface + Saved func() error + type SavingHook interface + Saving func() error + type TransactionFunc func(session mongo.Session, sc mongo.SessionContext) error + type UpdatedHook interface + Updated func(result *mongo.UpdateResult) error + type UpdatingHook interface + Updating func() error Other modules containing this package github.com/Kamva/mgm github.com/Kamva/mgm/v3