mongodb

package
v0.0.0-...-99e730b Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBAdapter

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

MongoDBAdapter implements the DocumentDB interface for MongoDB

func NewMongoDBAdapter

func NewMongoDBAdapter(config *documents.DocDBConfig) *MongoDBAdapter

NewMongoDBAdapter creates a new MongoDB adapter

func (*MongoDBAdapter) Aggregate

func (m *MongoDBAdapter) Aggregate(ctx context.Context, collection string, pipeline []map[string]interface{}) ([]map[string]interface{}, error)

Aggregate performs an aggregation operation

func (*MongoDBAdapter) Close

func (m *MongoDBAdapter) Close() error

Close closes the MongoDB connection

func (*MongoDBAdapter) CollectionExists

func (m *MongoDBAdapter) CollectionExists(ctx context.Context, name string) (bool, error)

CollectionExists checks if a collection exists

func (*MongoDBAdapter) Connect

func (m *MongoDBAdapter) Connect(config *documents.DocDBConfig) error

Connect establishes connection to MongoDB

func (*MongoDBAdapter) CountDocuments

func (m *MongoDBAdapter) CountDocuments(ctx context.Context, collection string, filter interface{}) (int64, error)

CountDocuments counts documents matching the filter

func (*MongoDBAdapter) CreateCollection

func (m *MongoDBAdapter) CreateCollection(ctx context.Context, name string) error

CreateCollection creates a new collection

func (*MongoDBAdapter) CreateIndex

func (m *MongoDBAdapter) CreateIndex(ctx context.Context, collection string, keys map[string]int, opts *documents.IndexOptions) error

CreateIndex creates an index on a collection

func (*MongoDBAdapter) DeleteMany

func (m *MongoDBAdapter) DeleteMany(ctx context.Context, collection string, filter interface{}) (int64, error)

DeleteMany deletes multiple documents

func (*MongoDBAdapter) DeleteOne

func (m *MongoDBAdapter) DeleteOne(ctx context.Context, collection string, filter interface{}) error

DeleteOne deletes a single document

func (*MongoDBAdapter) DropCollection

func (m *MongoDBAdapter) DropCollection(ctx context.Context, name string) error

DropCollection drops a collection

func (*MongoDBAdapter) DropIndex

func (m *MongoDBAdapter) DropIndex(ctx context.Context, collection string, name string) error

DropIndex drops an index from a collection

func (*MongoDBAdapter) FindMany

func (m *MongoDBAdapter) FindMany(ctx context.Context, collection string, filter interface{}, opts *documents.FindOptions) ([]map[string]interface{}, error)

FindMany finds multiple documents

func (*MongoDBAdapter) FindOne

func (m *MongoDBAdapter) FindOne(ctx context.Context, collection string, filter interface{}) (map[string]interface{}, error)

FindOne finds a single document

func (*MongoDBAdapter) GetType

func (m *MongoDBAdapter) GetType() documents.DocDBType

GetType returns the database type

func (*MongoDBAdapter) InsertMany

func (m *MongoDBAdapter) InsertMany(ctx context.Context, collection string, docs []interface{}) ([]string, error)

InsertMany inserts multiple documents

func (*MongoDBAdapter) InsertOne

func (m *MongoDBAdapter) InsertOne(ctx context.Context, collection string, document interface{}) (string, error)

InsertOne inserts a single document

func (*MongoDBAdapter) IsConnected

func (m *MongoDBAdapter) IsConnected() bool

IsConnected checks if the adapter is connected

func (*MongoDBAdapter) ListCollections

func (m *MongoDBAdapter) ListCollections(ctx context.Context) ([]string, error)

ListCollections lists all collections in the database

func (*MongoDBAdapter) ListIndexes

func (m *MongoDBAdapter) ListIndexes(ctx context.Context, collection string) ([]documents.IndexInfo, error)

ListIndexes lists all indexes on a collection

func (*MongoDBAdapter) Ping

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

Ping checks the connection to MongoDB

func (*MongoDBAdapter) Stats

Stats returns database statistics

func (*MongoDBAdapter) UpdateMany

func (m *MongoDBAdapter) UpdateMany(ctx context.Context, collection string, filter interface{}, update interface{}) (int64, error)

UpdateMany updates multiple documents

func (*MongoDBAdapter) UpdateOne

func (m *MongoDBAdapter) UpdateOne(ctx context.Context, collection string, filter interface{}, update interface{}) error

UpdateOne updates a single document

Jump to

Keyboard shortcuts

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