Skip to content

Commit

Permalink
fix(docs/bot): database config for typescript bump to 4.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barthofu committed Mar 7, 2023
1 parent 5eb85b9 commit 6986478
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions docs/bot/features/database/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,27 @@ Plus, SQLite is the only database supported by the **[automatic backup system](/

You can configure all of this in the `src/config/database.ts` file.

Indeed, this file exports a `databaseType` and a `mikroOrmConfig` constant, which contains a production configuration and an optional development configuration. At runtime, the good configuration is chosen thanks to the NODE_ENV environment variable.
The database type should be explicitely set in the `databaseType` constant as it will be used to determine which entity manager type Mikro-ORM should use internaly.
Indeed, this file exports a a `mikroOrmConfig` constant, which contains a production configuration and an optional development configuration. At runtime, the good configuration is chosen thanks to the NODE_ENV environment variable.
The database type should be explicitely set in the `mikroOrmConfig.production.type` constant as it will be used to determine which entity manager type Mikro-ORM should use internaly.

You can find here the configuration for the different types of databases:

<Tabs>
<Tab label="SQLite" value="sqlite">

```ts title=databaseType
export const databaseType = 'better-sqlite' as const // (or 'sqlite')
```

```ts title=mikroOrmConfig
{
type: databaseType,
type: 'better-sqlite', // or 'sqlite'
dbName: `${databaseConfig.path}db.sqlite`, // path to the db .sqlite file
}
```
</Tab>

<Tab label="PostgreSQL" value="postgresql">

```ts title=databaseType
export const databaseType = 'postgresql' as const
```

```ts title=mikroOrmConfig
{
type: databaseType,
type: 'postgres',
dbName: process.env['DATABASE_NAME'],
host: process.env['DATABASE_HOST'],
port: 5432,
Expand All @@ -62,10 +54,6 @@ export const databaseType = 'postgresql' as const

<Tab label="MySQL" value="mysql">

```ts title=databaseType
export const databaseType = 'mysql' as const
```

```ts title=mikroOrmConfig
{
type: 'mysql',
Expand All @@ -80,10 +68,6 @@ export const databaseType = 'mysql' as const

<Tab label="MariaDB" value="mariadb">

```ts title=databaseType
export const databaseType = 'mariadb' as const
```

```ts title=mikroOrmConfig
{
type: 'mariadb',
Expand All @@ -95,6 +79,17 @@ export const databaseType = 'mariadb' as const
}
```

</Tab>

<Tab label="MongoDB" value="mongo">

```ts title=mikroOrmConfig
{
type: 'mongo',
clientUrl: process.env['DATABASE_HOST'],
}
```

</Tab>
</Tabs>

Expand Down

0 comments on commit 6986478

Please sign in to comment.