Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/database/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func newMongoClientFromComponents(ctx context.Context, options *MongoOptions) (D
}, err
}

// Ping pings the MongoDB server to check connectivity
func (m *MongoClient) Ping(ctx context.Context) error {
err := m.Client.Ping(ctx, nil)
return err
Expand All @@ -185,6 +186,11 @@ func (m *MongoClient) Disconnect(ctx context.Context) error {
return m.Client.Disconnect(ctx)
}

// GetTimeout returns the timeout duration for the MongoDB client
func (m *MongoClient) GetTimeout() time.Duration {
return time.Duration(m.Options.Timeout) * time.Millisecond
}

// Find executes a find query on the specified database and collection
func (m *MongoClient) Find(ctx context.Context, db string, collection string, filter any, opts ...any) (any, error) {
coll := m.Client.Database(db).Collection(collection)
Expand Down
Loading