forked from BuildTheEarth/main-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.cjs
34 lines (28 loc) · 1.06 KB
/
ormconfig.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require('fs')
const JSON5 = require('json5')
const content = fs.readFileSync(__dirname + "/config/config.json5", {encoding: "utf-8"})
const config = JSON5.parse(content)
if (config.database.type == "mysql" || config.database.type == "mariadb") module.exports = {
type: process.env.DB_TYPE || "mysql",
host: process.env.DB_HOST || config.database.host,
database: process.env.DB_NAME|| config.database.name,
username: process.env.DB_USER ||config.database.user,
password: process.env.DB_PASS || config.database.pass,
migrations: ["dist/migrations/*.{js,ts}"],
entities: ["src/entities/*.entity.{js,ts}"],
cli: {
migrationsDir: "src/migrations",
entitiesDir: "src/entities",
}
}
const sqlite = {
database: config.database.path,
type: "better-sqlite3",
migrations: ["dist/migrations/*.{js,ts}"],
entities: ["src/entities/*.entity.{js,ts}"],
cli: {
migrationsDir: "src/migrations",
entitiesDir: "src/entities",
}
}
if (config.database.type == "sqlite") module.exports = sqlite