Documentation ¶
Index ¶
- func CloseCursor(ctx context.Context, cursor *mongo.Cursor)
- func Readme() string
- type ClientOption
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, pipeline mongo.Pipeline, results interface{}, ...) 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 interface{}, opts ...*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 interface{}, opts ...*options.FindOptions) error
- func (c *Collection) FindIterate(ctx context.Context, filter interface{}, handler IterateHandlerFn, ...) error
- func (c *Collection) FindOne(ctx context.Context, filter, result interface{}, ...) error
- func (c *Collection) Get(ctx context.Context, id string, result interface{}, ...) 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(v time.Duration) CollectionOption
- func CollectionWithIndexesQuorumMajority() CollectionOption
- func CollectionWithReadConcern(v *readconcern.ReadConcern) CollectionOption
- func CollectionWithReadPreference(v *readpref.ReadPref) CollectionOption
- func CollectionWithRegistry(v *bsoncodec.Registry) CollectionOption
- func CollectionWithWriteConcern(v *writeconcern.WriteConcern) CollectionOption
- type CollectionOptions
- type DatabaseOption
- type DecodeFn
- type Entity
- type EntityWithTimestamps
- type EntityWithVersion
- type IterateHandlerFn
- type 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
Types ¶
type ClientOption ¶ added in v0.18.0
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) Aggregate ¶
func (c *Collection) Aggregate(ctx context.Context, pipeline mongo.Pipeline, results interface{}, opts ...*options.AggregateOptions) error
func (*Collection) AggregateIterate ¶
func (c *Collection) AggregateIterate(ctx context.Context, pipeline mongo.Pipeline, handler IterateHandlerFn, opts ...*options.AggregateOptions) error
func (*Collection) Col ¶
func (c *Collection) Col() *mongo.Collection
func (*Collection) Count ¶
func (c *Collection) Count(ctx context.Context, filter interface{}, opts ...*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 ¶ added in v0.9.10
func (c *Collection) DB() *mongo.Database
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, filter, results interface{}, opts ...*options.FindOptions) error
func (*Collection) FindIterate ¶
func (c *Collection) FindIterate(ctx context.Context, filter interface{}, handler IterateHandlerFn, opts ...*options.FindOptions) error
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, filter, result interface{}, opts ...*options.FindOneOptions) error
func (*Collection) Get ¶
func (c *Collection) Get(ctx context.Context, id string, result interface{}, opts ...*options.FindOneOptions) error
func (*Collection) Insert ¶ added in v0.5.0
func (c *Collection) Insert(ctx context.Context, entity Entity) error
func (*Collection) InsertMany ¶ added in v0.13.0
func (c *Collection) InsertMany(ctx context.Context, entities []Entity) error
func (*Collection) UpsertMany ¶ added in v0.13.0
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 ¶
func CollectionWithIndexesMaxTime(v time.Duration) CollectionOption
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 *bsoncodec.Registry) CollectionOption
func CollectionWithWriteConcern ¶
func CollectionWithWriteConcern(v *writeconcern.WriteConcern) CollectionOption
type CollectionOptions ¶
type CollectionOptions struct { *options.CollectionOptions *options.CreateIndexesOptions Indexes []mongo.IndexModel IndexesContext context.Context }
Collection can only be used in the Persistor.WithCollection call.ss
func DefaultCollectionOptions ¶
func DefaultCollectionOptions() CollectionOptions
type DatabaseOption ¶ added in v0.18.0
type DatabaseOption func(*options.DatabaseOptions)
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 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 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