> For the complete documentation index, see [llms.txt](https://myroslavs-organization.gitbook.io/orm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://myroslavs-organization.gitbook.io/orm/configuration.md).

# Configuration

This section describes all configuration parameters used for setting up my ORM system. The configuration includes database connection settings, caching parameters, and other important options.

**Connection Parameters**

`ConnectionData` defines the essential parameters for connecting to the database and configuring the ORM:

* **host:** The address of the database server.
* **user:** The username for connecting to the database.
* **password:** The password for connecting to the database.
* **port:** The port on which the database is running.
* **type (DatabasesTypes):** The type of database to which the ORM connects. It can be:
  * `DatabasesTypes.POSTGRES` for PostgreSQL
  * `DatabasesTypes.MYSQL` for MySQL
* **models (ClassInterface\[]):** An array of model classes to be used by the ORM. This allows the ORM to know which tables to work with.
* **migrationTable (string):** The name of the table for storing database migration information.
* **migrationTableSchema (string):** The schema of the table for storing migration information.
* **database (string):** The name of the database to connect to.
* **logging (boolean):** Enable or disable query logging. If `true`, all queries will be logged.
* **monitoring (boolean):** Enable or disable query monitoring. If `true`, statistical data about queries will be collected.
* **sanitizer (boolean):** Enable or disable automatic sanitization of input data to prevent SQL injections.

**cache (object):** Caching settings:

* **type (CacheType):** The type of cache used. It can be:
  * `'redis'` for Redis
  * `'memcached'` (not yet implemented)
* **options (CacheOptions):** Caching options:
  * **url (string):** URL of the caching server.
  * **username (string):** Username for connecting to the caching server.
  * **password (string):** Password for connecting to the caching server.
  * **name (string):** Name of the cache.
  * **database (number):** Number of the cache database.
  * **socket (object):** Socket options for connecting to the caching server:
    * **connectTimeout (number):** Connection timeout.
    * **noDelay (boolean):** Disable or enable send delay.
    * **keepAlive (number | false):** Keep-alive interval or `false`.
    * **reconnectStrategy (false | number | function):** Reconnection strategy.
    * **tls (any):** TLS options for secure connection.

**Example of Connecting to the Database:**

```typescript
export const databaseManager = new DatabaseManager<DatabasesTypes.POSTGRES>(
    {
        type: DatabasesTypes.POSTGRES,
        host: 'localhost',
        user: 'postgres',
        password: 'xxx',
        port: 5432,
        database: 'first',
        models: [Users],
        logging: true, // активація логування запитів
        monitoring: true, // активація моніторингу
        sanitizer: true, // активація очищення вводу
        cache: {
            type: 'redis', // тип кешування
        }
    },
    new DataSourceContext()
);

// Створення ORM підключення
(async () => {
    await databaseManager.createOrmConnection();
})();
```

This point provides detailed information about the configuration options for my ORM system, including database connection and caching options, as well as a basic connection example for PostgreSQL.
