mongodb

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionHandler

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

CollectionHandler provides operations on a single MongoDB collection.

func (*CollectionHandler) Aggregate

func (c *CollectionHandler) Aggregate(pipeline []map[string]interface{}) ([]map[string]interface{}, error)

Aggregate executes an aggregation pipeline.

func (*CollectionHandler) CountDocuments

func (c *CollectionHandler) CountDocuments(filter map[string]interface{}) (int64, error)

CountDocuments counts documents matching the filter.

func (*CollectionHandler) CreateIndex

func (c *CollectionHandler) CreateIndex(keys map[string]interface{}, unique bool) (string, error)

CreateIndex creates an index on the collection.

func (*CollectionHandler) DeleteMany

func (c *CollectionHandler) DeleteMany(filter map[string]interface{}) (int64, error)

DeleteMany deletes all documents matching the filter.

func (*CollectionHandler) DeleteOne

func (c *CollectionHandler) DeleteOne(filter map[string]interface{}) (int64, error)

DeleteOne deletes the first document matching the filter.

func (*CollectionHandler) DropIndex

func (c *CollectionHandler) DropIndex(name string) error

DropIndex drops an index by name.

func (*CollectionHandler) Find

func (c *CollectionHandler) Find(filter map[string]interface{}) ([]map[string]interface{}, error)

Find returns all documents matching the filter.

func (*CollectionHandler) FindOne

func (c *CollectionHandler) FindOne(filter map[string]interface{}) (map[string]interface{}, error)

FindOne returns the first document matching the filter.

func (*CollectionHandler) InsertMany

func (c *CollectionHandler) InsertMany(docs []map[string]interface{}) ([]interface{}, error)

InsertMany inserts multiple documents and returns the inserted IDs.

func (*CollectionHandler) InsertOne

func (c *CollectionHandler) InsertOne(doc map[string]interface{}) (interface{}, error)

InsertOne inserts a single document and returns the inserted ID.

func (*CollectionHandler) UpdateMany

func (c *CollectionHandler) UpdateMany(filter map[string]interface{}, update map[string]interface{}) (int64, error)

UpdateMany updates all documents matching the filter.

func (*CollectionHandler) UpdateOne

func (c *CollectionHandler) UpdateOne(filter map[string]interface{}, update map[string]interface{}) (int64, error)

UpdateOne updates the first document matching the filter.

type Handler

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

Handler wraps a MongoDB client and provides database operations for GlyphLang.

func NewHandler

func NewHandler(client *mongo.Client, dbName string) *Handler

NewHandler creates a Handler from an existing MongoDB client and database name.

func NewHandlerFromURI

func NewHandlerFromURI(uri string, dbName string) (*Handler, error)

NewHandlerFromURI creates a Handler by connecting to the given MongoDB URI.

func (*Handler) Close

func (h *Handler) Close() error

Close disconnects the MongoDB client.

func (*Handler) Collection

func (h *Handler) Collection(name string) *CollectionHandler

Collection returns a CollectionHandler for the named collection.

func (*Handler) Ping

func (h *Handler) Ping() error

Ping verifies the MongoDB connection is alive.

type MockCollectionHandler

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

MockCollectionHandler provides in-memory document operations.

func (*MockCollectionHandler) Aggregate

func (c *MockCollectionHandler) Aggregate(pipeline []map[string]interface{}) ([]map[string]interface{}, error)

Aggregate is a simplified mock that returns all documents (real aggregation is not supported in mock).

func (*MockCollectionHandler) CountDocuments

func (c *MockCollectionHandler) CountDocuments(filter map[string]interface{}) (int64, error)

CountDocuments counts matching documents.

func (*MockCollectionHandler) CreateIndex

func (c *MockCollectionHandler) CreateIndex(keys map[string]interface{}, unique bool) (string, error)

CreateIndex is a no-op in the mock. Returns a generated index name.

func (*MockCollectionHandler) DeleteMany

func (c *MockCollectionHandler) DeleteMany(filter map[string]interface{}) (int64, error)

DeleteMany deletes all matching documents.

func (*MockCollectionHandler) DeleteOne

func (c *MockCollectionHandler) DeleteOne(filter map[string]interface{}) (int64, error)

DeleteOne deletes the first matching document.

func (*MockCollectionHandler) DropIndex

func (c *MockCollectionHandler) DropIndex(name string) error

DropIndex is a no-op in the mock.

func (*MockCollectionHandler) Find

func (c *MockCollectionHandler) Find(filter map[string]interface{}) ([]map[string]interface{}, error)

Find returns all documents matching the filter.

func (*MockCollectionHandler) FindOne

func (c *MockCollectionHandler) FindOne(filter map[string]interface{}) (map[string]interface{}, error)

FindOne returns the first document matching the filter.

func (*MockCollectionHandler) InsertMany

func (c *MockCollectionHandler) InsertMany(docs []map[string]interface{}) ([]interface{}, error)

InsertMany inserts multiple documents.

func (*MockCollectionHandler) InsertOne

func (c *MockCollectionHandler) InsertOne(doc map[string]interface{}) (interface{}, error)

InsertOne inserts a single document.

func (*MockCollectionHandler) UpdateMany

func (c *MockCollectionHandler) UpdateMany(filter map[string]interface{}, update map[string]interface{}) (int64, error)

UpdateMany updates all matching documents.

func (*MockCollectionHandler) UpdateOne

func (c *MockCollectionHandler) UpdateOne(filter map[string]interface{}, update map[string]interface{}) (int64, error)

UpdateOne updates the first matching document.

type MockHandler

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

MockHandler provides an in-memory MongoDB-like handler for testing.

func NewMockHandler

func NewMockHandler() *MockHandler

NewMockHandler creates a new MockHandler.

func (*MockHandler) Close

func (m *MockHandler) Close() error

Close is a no-op for the mock.

func (*MockHandler) Collection

func (m *MockHandler) Collection(name string) *MockCollectionHandler

Collection returns a MockCollectionHandler for the named collection.

func (*MockHandler) Ping

func (m *MockHandler) Ping() error

Ping always succeeds for the mock.

Jump to

Keyboard shortcuts

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