Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql addition #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Haris-Hambasic
Copy link

Summary

This pull request introduces support for pure MySQL connections alongside the existing Sequelize-based PostgreSQL support. The changes enhance the flexibility and scalability of the database layer, enabling developers to choose between using Sequelize or a native MySQL connection based on project requirements.
Changes Introduced

New Functionality:

  1. Added connectDatabaseMySQL:
  2. A function for establishing direct MySQL connections using the mysql2 library with support for SSL and optional logging.
  3. Enhanced connectDatabaseSequelize:
  4. Maintains robust PostgreSQL support via Sequelize, with improved defaults and error handling.
  5. Unified Export:
  6. Introduced DatabaseConnector: A unified object that consolidates both Sequelize and MySQL connection functions for seamless integration.
  7. Error Handling:
  8. Comprehensive error handling with descriptive messages for both MySQL and Sequelize connections to simplify debugging and ensure production readiness.
  9. Default Parameters:
  10. Default ports for PostgreSQL (5432) and MySQL (3306). Optional SSL support with proper configuration for MySQL connections.

Implementation Details

  1. MySQL Connection (connectDatabaseMySQL)
  2. Uses the mysql2/promise package to create a direct connection. Tests the connection with connection.ping() to ensure availability. Includes optional SSL support (sslEnabled flag) for secure connections. Allows logging of successful connections via an optional logging function.
  3. Sequelize Connection (connectDatabaseSequelize)
  4. Maintains existing Sequelize connection logic for PostgreSQL. Improved defaults for port, pool settings, and SSL. Ensures compatibility with existing Sequelize integrations.
  5. Unified Export
  6. Combines both connection methods under DatabaseConnector:
    DatabaseConnector.sequelize(); // For Sequelize connections DatabaseConnector.mysql(); // For MySQL connections

…ctions

- Implemented  to establish pure MySQL connections using .

- Enhanced  to maintain robust PostgreSQL support via Sequelize.

- Unified export under  for seamless selection of database connection methods.
…ctions

- Implemented connectDatabaseMySQL to establish pure MySQL connections using .

- Enhanced connectDatabaseSequelize to maintain robust PostgreSQL support via Sequelize.

- Unified export under DatabaseConnector for seamless selection of database connection methods.

- Added default parameters (e.g., port numbers, SSL settings) to minimize configuration errors.

- Introduced comprehensive error handling with clear logs for easier debugging.

- Included optional logging support for MySQL connections.

- Updated inline documentation and examples for developer clarity and usability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant