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:
n.nakhostin
2025-09-09 18:53:39 +03:30
parent 57c29dc58f
commit 5d721705b7
24 changed files with 64 additions and 130 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ package user
import (
"tm/pkg/mongo"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
// UserRole represents user roles in the system
@@ -44,7 +44,7 @@ type User struct {
// SetID sets the user ID (implements IDSetter interface)
func (u *User) SetID(id string) {
u.ID, _ = primitive.ObjectIDFromHex(id)
u.ID, _ = bson.ObjectIDFromHex(id)
}
// GetID returns the user ID (implements IDGetter interface)
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"tm/pkg/response"
"github.com/labstack/echo/v4"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)
// AuthMiddleware validates JWT access tokens and extracts user information
@@ -44,7 +44,7 @@ func (h *Handler) AuthMiddleware() echo.MiddlewareFunc {
}
// Extract user information from token
userID, err := primitive.ObjectIDFromHex(validationResult.Claims.UserID)
userID, err := bson.ObjectIDFromHex(validationResult.Claims.UserID)
if err != nil {
h.logger.Error("Failed to parse user ID from token", map[string]interface{}{
"error": err.Error(),
+1 -1
View File
@@ -8,7 +8,7 @@ import (
orm "tm/pkg/mongo"
"tm/pkg/response"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)
// Repository defines methods for user data access
+2 -2
View File
@@ -9,7 +9,7 @@ import (
"tm/pkg/logger"
"tm/pkg/response"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
"golang.org/x/crypto/bcrypt"
)
@@ -368,7 +368,7 @@ func (s *userService) RefreshToken(ctx context.Context, refreshToken string) (*A
}
// Get user information
userID, err := primitive.ObjectIDFromHex(validationResult.Claims.UserID)
userID, err := bson.ObjectIDFromHex(validationResult.Claims.UserID)
if err != nil {
s.logger.Error("Failed to parse user ID from token", map[string]interface{}{
"error": err.Error(),