Documentation
¶
Index ¶
- func CloseCursor(ctx context.Context, cursor *mongo.Cursor)
- func Readme() string
- func WithClientCompression(o *Options)
- type ClientLoggerOption
- type ClientOption
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, pipeline mongo.Pipeline, results any, ...) error
- func (c *Collection) AggregateIterate(ctx context.Context, pipeline mongo.Pipeline, handler IterateHandlerFn, ...) error
- func (c *Collection) Col() *mongo.Collection
- func (c *Collection) Count(ctx context.Context, filter any, opts ...options.Lister[options.CountOptions]) (int64, error)
- func (c *Collection) CountAll(ctx context.Context) (int64, error)
- func (c *Collection) DB() *mongo.Database
- func (c *Collection) Delete(ctx context.Context, id string) error
- func (c *Collection) Exists(ctx context.Context, id string) (bool, error)
- func (c *Collection) Find(ctx context.Context, filter, results any, ...) error
- func (c *Collection) FindIterate(ctx context.Context, filter any, handler IterateHandlerFn, ...) error
- func (c *Collection) FindOne(ctx context.Context, filter, result any, ...) error
- func (c *Collection) Get(ctx context.Context, id string, result any, ...) error
- func (c *Collection) Insert(ctx context.Context, entity Entity) error
- func (c *Collection) InsertMany(ctx context.Context, entities []Entity) error
- func (c *Collection) Upsert(ctx context.Context, id string, entity Entity) error
- func (c *Collection) UpsertMany(ctx context.Context, entities []Entity) error
- type CollectionOption
- func CollectionWithIndexes(v ...mongo.IndexModel) CollectionOption
- func CollectionWithIndexesCommitQuorumString(v string) CollectionOption
- func CollectionWithIndexesCommitQuorumVotingMembers(v context.Context) CollectionOption
- func CollectionWithIndexesContext(v int32) CollectionOption
- func CollectionWithIndexesMaxTime(_ time.Duration) CollectionOptiondeprecated
- func CollectionWithIndexesQuorumMajority() CollectionOption
- func CollectionWithReadConcern(v *readconcern.ReadConcern) CollectionOption
- func CollectionWithReadPreference(v *readpref.ReadPref) CollectionOption
- func CollectionWithRegistry(v *bson.Registry) CollectionOption
- func CollectionWithWriteConcern(v *writeconcern.WriteConcern) CollectionOption
- type CollectionOptions
- type DatabaseOption
- type DecodeFn
- type Entity
- type EntityWithTimestamps
- type EntityWithVersion
- type IterateHandlerFn
- type Option
- func WithClientLogger(v *zap.Logger) Option
- func WithClientLoggerComponentLevel(c options.LogComponent, l options.LogLevel) Option
- func WithClientOptions(v ...ClientOption) Option
- func WithDatabaseOptions(v ...DatabaseOption) Option
- func WithOtelEnabled(v bool) Option
- func WithOtelOptions(v ...otelmongo.Option) Option
- type Options
- type Persistor
- func (p Persistor) Client() *mongo.Client
- func (p Persistor) Close(ctx context.Context) error
- func (p Persistor) Collection(name string, opts ...CollectionOption) (*Collection, error)
- func (p Persistor) DB() *mongo.Database
- func (p Persistor) HasCollection(ctx context.Context, name string) (bool, error)
- func (p Persistor) Ping(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseCursor ¶
CloseCursor with defer
func WithClientCompression ¶
func WithClientCompression(o *Options)
Types ¶
type ClientLoggerOption ¶
type ClientLoggerOption func(*options.LoggerOptions)
Persistor exported to used also for embedding into other types in foreign packages.
type ClientOption ¶
type ClientOption func(*options.ClientOptions)
Persistor exported to used also for embedding into other types in foreign packages.
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection can only be used in the Persistor.WithCollection call.ss
func NewCollection ¶
func NewCollection(db *mongo.Database, name string, opts ...CollectionOption) (*Collection, error)
func (*Collection) AggregateIterate ¶
func (c *Collection) AggregateIterate(ctx context.Context, pipeline mongo.Pipeline, handler IterateHandlerFn, opts ...options.Lister[options.AggregateOptions]) error
func (*Collection) Col ¶
func (c *Collection) Col() *mongo.Collection
func (*Collection) Count ¶
func (c *Collection) Count(ctx context.Context, filter any, opts ...options.Lister[options.CountOptions]) (int64, error)
Count returns the count of documents
func (*Collection) CountAll ¶
func (c *Collection) CountAll(ctx context.Context) (int64, error)
CountAll returns the count of all documents
func (*Collection) DB ¶
func (c *Collection) DB() *mongo.Database
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, filter, results any, opts ...options.Lister[options.FindOptions]) error
func (*Collection) FindIterate ¶
func (c *Collection) FindIterate(ctx context.Context, filter any, handler IterateHandlerFn, opts ...options.Lister[options.FindOptions]) error
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, filter, result any, opts ...options.Lister[options.FindOneOptions]) error
func (*Collection) Get ¶
func (c *Collection) Get(ctx context.Context, id string, result any, opts ...options.Lister[options.FindOneOptions]) error
func (*Collection) InsertMany ¶
func (c *Collection) InsertMany(ctx context.Context, entities []Entity) error
func (*Collection) UpsertMany ¶
func (c *Collection) UpsertMany(ctx context.Context, entities []Entity) error
UpsertMany - NOTE: upsert many does NOT through an explicit error on dirty write so we can only assume it.
type CollectionOption ¶
type CollectionOption func(*CollectionOptions)
Collection can only be used in the Persistor.WithCollection call.ss
func CollectionWithIndexes ¶
func CollectionWithIndexes(v ...mongo.IndexModel) CollectionOption
func CollectionWithIndexesCommitQuorumString ¶
func CollectionWithIndexesCommitQuorumString(v string) CollectionOption
func CollectionWithIndexesCommitQuorumVotingMembers ¶
func CollectionWithIndexesCommitQuorumVotingMembers(v context.Context) CollectionOption
func CollectionWithIndexesContext ¶
func CollectionWithIndexesContext(v int32) CollectionOption
func CollectionWithIndexesMaxTime
deprecated
func CollectionWithIndexesMaxTime(_ time.Duration) CollectionOption
Deprecated: MaxTime has been removed in mongo-driver v2. Use context timeout instead.
func CollectionWithIndexesQuorumMajority ¶
func CollectionWithIndexesQuorumMajority() CollectionOption
func CollectionWithReadConcern ¶
func CollectionWithReadConcern(v *readconcern.ReadConcern) CollectionOption
func CollectionWithReadPreference ¶
func CollectionWithReadPreference(v *readpref.ReadPref) CollectionOption
func CollectionWithRegistry ¶
func CollectionWithRegistry(v *bson.Registry) CollectionOption
func CollectionWithWriteConcern ¶
func CollectionWithWriteConcern(v *writeconcern.WriteConcern) CollectionOption
type CollectionOptions ¶
type CollectionOptions struct {
*options.CollectionOptionsBuilder
*options.CreateIndexesOptionsBuilder
Indexes []mongo.IndexModel
IndexesContext context.Context
}
Collection can only be used in the Persistor.WithCollection call.ss
func DefaultCollectionOptions ¶
func DefaultCollectionOptions() CollectionOptions
type DatabaseOption ¶
type DatabaseOption func(*options.DatabaseOptionsBuilder)
Persistor exported to used also for embedding into other types in foreign packages.
type EntityWithTimestamps ¶
type EntityWithVersion ¶
type IterateHandlerFn ¶
type Option ¶
type Option func(o *Options)
Persistor exported to used also for embedding into other types in foreign packages.
func WithClientLogger ¶
func WithClientLoggerComponentLevel ¶
func WithClientLoggerComponentLevel(c options.LogComponent, l options.LogLevel) Option
func WithClientOptions ¶
func WithClientOptions(v ...ClientOption) Option
func WithDatabaseOptions ¶
func WithDatabaseOptions(v ...DatabaseOption) Option
func WithOtelEnabled ¶
func WithOtelOptions ¶
type Options ¶
type Options struct {
OtelEnabled bool
OtelOptions []otelmongo.Option
ClientOptions []ClientOption
ClientLoggerOptions []ClientLoggerOption
DatabaseOptions []DatabaseOption
}
Persistor exported to used also for embedding into other types in foreign packages.
func DefaultOptions ¶
func DefaultOptions() Options
type Persistor ¶
type Persistor struct {
// contains filtered or unexported fields
}
Persistor exported to used also for embedding into other types in foreign packages.
func (Persistor) Collection ¶
func (p Persistor) Collection(name string, opts ...CollectionOption) (*Collection, error)
func (Persistor) HasCollection ¶
HasCollection checks if the given collection exists