implemented mongo gridFS for file upload

This commit is contained in:
m.nazemi
2026-04-21 19:07:51 +03:30
parent 74d9269a19
commit 3aabd95b1c
16 changed files with 1941 additions and 17 deletions
+19
View File
@@ -204,6 +204,25 @@ func (cm *ConnectionManager) Close(ctx context.Context) error {
return nil
}
// IsConnected checks if MongoDB connection is active
func (cm *ConnectionManager) IsConnected() bool {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
err := cm.Ping(ctx)
return err == nil
}
// GetDatabase returns the MongoDB database instance
func (cm *ConnectionManager) GetDatabase() *mongo.Database {
return cm.database
}
// GetClient returns the MongoDB client instance
func (cm *ConnectionManager) GetClient() *mongo.Client {
return cm.client
}
// Ping pings the MongoDB server
func (cm *ConnectionManager) Ping(ctx context.Context) error {
if err := cm.client.Ping(ctx, readpref.Primary()); err != nil {