connection

package
v0.0.0-...-b5aee91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeStream

type ChangeStream interface {
	Next(ctx context.Context) bool
	Decode(val interface{}) error
	Err() error
	Close(ctx context.Context) error
	ResumeToken() []byte
}

type Client

type Client interface {
	Database(name string) Database
	Close(ctx context.Context) error
	Ping(ctx context.Context) error
}

func NewMongoClient

func NewMongoClient(cfg config.MongoDB) (Client, error)

type Collection

type Collection interface {
	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (ChangeStream, error)
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) SingleResult
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (Cursor, error)
	InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (InsertResult, error)
	UpdateOne(
		ctx context.Context,
		filter interface{},
		update interface{},
		opts ...*options.UpdateOptions,
	) (UpdateResult, error)
	UpdateMany(
		ctx context.Context,
		filter interface{},
		update interface{},
		opts ...*options.UpdateOptions,
	) (UpdateResult, error)
	FindOneAndUpdate(
		ctx context.Context,
		filter interface{},
		update interface{},
		opts ...*options.FindOneAndUpdateOptions,
	) SingleResult
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (DeleteResult, error)
	DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (DeleteResult, error)
	CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
	Indexes() IndexView
}

type Cursor

type Cursor interface {
	Next(ctx context.Context) bool
	Decode(val interface{}) error
	Close(ctx context.Context) error
	Err() error
}

type Database

type Database interface {
	Collection(name string) Collection
	CollectionWithReadPref(name string, rp *readpref.ReadPref) Collection
	RunCommand(ctx context.Context, runCommand interface{}) SingleResult
}

type DeleteResult

type DeleteResult interface {
	DeletedCount() int64
}

type IndexView

type IndexView interface {
	CreateMany(ctx context.Context, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)
}

type InsertResult

type InsertResult interface {
	InsertedID() interface{}
}

type MongoClient

type MongoClient struct {
	// contains filtered or unexported fields
}

func (*MongoClient) Close

func (m *MongoClient) Close(ctx context.Context) error

func (*MongoClient) Database

func (m *MongoClient) Database(name string) Database

func (*MongoClient) GetClient

func (m *MongoClient) GetClient() *mongo.Client

func (*MongoClient) Ping

func (m *MongoClient) Ping(ctx context.Context) error

type SingleResult

type SingleResult interface {
	Decode(v interface{}) error
	Err() error
}

type UpdateResult

type UpdateResult interface {
	MatchedCount() int64
	ModifiedCount() int64
	UpsertedCount() int64
	UpsertedID() interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL