Update MongoDB Driver and Configuration for Company Entities
- Updated the MongoDB driver from v1.17.4 to v2.3.0, ensuring compatibility with the latest features and improvements. - Refactored company-related entity and repository files to utilize the new driver, replacing `primitive.ObjectID` with `bson.ObjectID` for ID handling. - Adjusted the configuration in `.drone.yml` to include the `main` branch in the trigger settings, enhancing CI/CD pipeline flexibility.
This commit is contained in:
@@ -5,10 +5,10 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.mongodb.org/mongo-driver/mongo/readpref"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
|
||||
)
|
||||
|
||||
// ConnectionConfig holds MongoDB connection configuration
|
||||
@@ -62,7 +62,7 @@ func NewConnectionManager(config ConnectionConfig, logger Logger) (*ConnectionMa
|
||||
ctx, cancel := context.WithTimeout(context.Background(), config.ConnectTimeout)
|
||||
defer cancel()
|
||||
|
||||
client, err := mongo.Connect(ctx, clientOptions)
|
||||
client, err := mongo.Connect(clientOptions)
|
||||
if err != nil {
|
||||
logger.Error("Failed to connect to MongoDB", map[string]interface{}{
|
||||
"uri": config.URI,
|
||||
@@ -144,7 +144,7 @@ func (cm *ConnectionManager) DropIndexes(collectionName string, indexNames []str
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
_, err := collection.Indexes().DropOne(ctx, indexName)
|
||||
err := collection.Indexes().DropOne(ctx, indexName)
|
||||
if err != nil {
|
||||
cm.logger.Error("Failed to drop index", map[string]interface{}{
|
||||
"collection": collectionName,
|
||||
|
||||
Reference in New Issue
Block a user