Versions in this module Expand all Collapse all v1 v1.3.0 Aug 13, 2022 v1.2.5 May 16, 2022 Changes in this version + 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 + func UpsertTrueOption() *options.UpdateOptions + type Collection struct + func Coll(m Model, opts ...*options.CollectionOptions) *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) SimpleAggregateCursorWithCtx(ctx context.Context, stages ...interface{}) (*mongo.Cursor, error) + func (coll *Collection) SimpleAggregateFirst(result interface{}, stages ...interface{}) (bool, error) + func (coll *Collection) SimpleAggregateFirstWithCtx(ctx context.Context, result interface{}, stages ...interface{}) (bool, error) + func (coll *Collection) SimpleAggregateWithCtx(ctx context.Context, results interface{}, stages ...interface{}) 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 CreatedHookWithCtx interface + Created func(context.Context) error + type CreatingHook interface + Creating func() error + type CreatingHookWithCtx interface + Creating func(context.Context) 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 DeletedHookWithCtx interface + Deleted func(ctx context.Context, result *mongo.DeleteResult) error + type DeletingHook interface + Deleting func() error + type DeletingHookWithCtx interface + Deleting func(context.Context) 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 SavedHookWithCtx interface + Saved func(context.Context) error + type SavingHook interface + Saving func() error + type SavingHookWithCtx interface + Saving func(context.Context) error + type TransactionFunc func(session mongo.Session, sc mongo.SessionContext) error + type UpdatedHook interface + Updated func(result *mongo.UpdateResult) error + type UpdatedHookWithCtx interface + Updated func(ctx context.Context, result *mongo.UpdateResult) error + type UpdatingHook interface + Updating func() error + type UpdatingHookWithCtx interface + Updating func(context.Context) error