# Database

File: `shared/config.lua` → `Config.Database`

***

Configures how player data is stored in MySQL / MariaDB.

## Fields

| Key               | Type      | Default            | Description                                                          |
| ----------------- | --------- | ------------------ | -------------------------------------------------------------------- |
| `AutoCreateTable` | `boolean` | `true`             | Automatically creates the database table on first startup.           |
| `TableName`       | `string`  | `'koja-lawnmower'` | Name of the database table.                                          |
| `StartingValues`  | `table`   | *(see below)*      | Default data assigned to a player when they join for the first time. |

## StartingValues

| Key           | Type     | Default       | Description                         |
| ------------- | -------- | ------------- | ----------------------------------- |
| `level`       | `number` | `1`           | Starting level.                     |
| `exp`         | `number` | `0`           | Starting experience points.         |
| `skillpoints` | `number` | `0`           | Starting skill points.              |
| `skills`      | `table`  | `{}`          | Unlocked skills (empty by default). |
| `history`     | `table`  | *(see below)* | Mission history object.             |

### history

| Key             | Type     | Default | Description                   |
| --------------- | -------- | ------- | ----------------------------- |
| `totalMissions` | `number` | `0`     | Lifetime missions completed.  |
| `totalEarnings` | `number` | `0`     | Lifetime money earned.        |
| `logs`          | `table`  | `{}`    | Array of mission log entries. |

## Example

{% code title="shared/config.lua" %}

```lua
Config.Database = {
    AutoCreateTable = true,
    TableName = 'koja-lawnmower',
    StartingValues = {
        level = 1,
        exp = 0,
        history = {
            totalMissions = 0,
            totalEarnings = 0,
            logs = {}
        },
        skillpoints = 0,
        skills = {}
    }
}
```

{% endcode %}
