Documentation ¶
Index ¶
- Constants
- Variables
- type Collection
- func (*Collection[T]) All(ctx context.Context, cur *mongo.Cursor) (docs []T, err error)
- func (c *Collection[T]) CountDocuments(ctx context.Context, filter any, opts ...*options.CountOptions) (count uint64, err error)
- func (*Collection[T]) Decode(r *mongo.SingleResult) (doc T, err error)
- func (c *Collection[T]) DeleteOne(ctx context.Context, filter any, opts ...*options.DeleteOptions) (err error)
- func (c *Collection[T]) Find(ctx context.Context, filter any, opts ...*options.FindOptions) (docs []T, err error)
- func (c *Collection[T]) FindOne(ctx context.Context, filter any, opts ...*options.FindOneOptions) (doc T, err error)
- func (*Collection[T]) FindOptions(index uint64, size uint32) *options.FindOptions
- func (c *Collection[T]) InsertOne(ctx context.Context, document T, opts ...*options.InsertOneOptions) (string, error)
- func (c *Collection[T]) NormalizeFilter(filter any) (data any, err error)
- func (*Collection[T]) ObjectID(id string) (primitive.ObjectID, error)
- func (c *Collection[T]) ToM(doc T) (bson.M, error)
- func (c *Collection[T]) UpdateOne(ctx context.Context, filter any, update any, opts ...*options.UpdateOptions) (err error)
- type Config
Constants ¶
View Source
const ( ErrMsgDecode = "failed to decode document due to error: %w" ErrMsgQuery = "failed to execute query due to error: %w" ErrMsgFromHex = "failed to convert hex to primitive.ObjectID due to error: %w" )
Variables ¶
View Source
var ErrNormalizeFilter = errors.New("couldn't normalize filter")
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection[T any] struct { Inner *mongo.Collection Log *zap.Logger }
func (*Collection[T]) CountDocuments ¶
func (c *Collection[T]) CountDocuments(ctx context.Context, filter any, opts ...*options.CountOptions) (count uint64, err error)
func (*Collection[T]) Decode ¶
func (*Collection[T]) Decode(r *mongo.SingleResult) (doc T, err error)
func (*Collection[T]) DeleteOne ¶
func (c *Collection[T]) DeleteOne(ctx context.Context, filter any, opts ...*options.DeleteOptions) (err error)
func (*Collection[T]) Find ¶
func (c *Collection[T]) Find(ctx context.Context, filter any, opts ...*options.FindOptions) (docs []T, err error)
func (*Collection[T]) FindOne ¶
func (c *Collection[T]) FindOne(ctx context.Context, filter any, opts ...*options.FindOneOptions) (doc T, err error)
func (*Collection[T]) FindOptions ¶
func (*Collection[T]) FindOptions(index uint64, size uint32) *options.FindOptions
func (*Collection[T]) InsertOne ¶
func (c *Collection[T]) InsertOne(ctx context.Context, document T, opts ...*options.InsertOneOptions) (string, error)
func (*Collection[T]) NormalizeFilter ¶
func (c *Collection[T]) NormalizeFilter(filter any) (data any, err error)
func (*Collection[T]) ObjectID ¶
func (*Collection[T]) ObjectID(id string) (primitive.ObjectID, error)
func (*Collection[T]) UpdateOne ¶
func (c *Collection[T]) UpdateOne(ctx context.Context, filter any, update any, opts ...*options.UpdateOptions) (err error)
Click to show internal directories.
Click to hide internal directories.