MCPcopy
hub / github.com/FoalTS/foal / createDataSource

Function createDataSource

packages/cli/templates/app/src/db.ts:5–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { DataSource } from 'typeorm';
4
5export function createDataSource(): DataSource {
6 return new DataSource({
7 type: Config.getOrThrow('database.type', 'string') as any,
8
9 url: Config.get('database.url', 'string'),
10 host: Config.get('database.host', 'string'),
11 port: Config.get('database.port', 'number'),
12 username: Config.get('database.username', 'string'),
13 password: Config.get('database.password', 'string'),
14 database: Config.get('database.database', 'string'),
15
16 dropSchema: Config.get('database.dropSchema', 'boolean', false),
17 synchronize: Config.get('database.synchronize', 'boolean', false),
18
19 entities: ['build/app/**/*.entity.js'],
20 migrations: ['build/migrations/*.js'],
21 });
22}
23
24export const dataSource = createDataSource();

Callers 4

index.tsFile · 0.90
db.tsFile · 0.70
controller.spec.tsFile · 0.50

Calls 2

getOrThrowMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected