mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
8 changed files with 3917 additions and 161 deletions
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,21 @@ |
|||||||
import { Global, Injectable } from '@nestjs/common' |
import { Global, Injectable, OnModuleInit } from '@nestjs/common'; |
||||||
|
|
||||||
import * as knex from "knex"; |
import * as knex from 'knex'; |
||||||
|
import NcConfigFactory from '../utils/NcConfigFactory'; |
||||||
|
|
||||||
@Global() |
@Global() |
||||||
|
|
||||||
@Injectable() |
@Injectable() |
||||||
export class Connection { |
export class Connection implements OnModuleInit { |
||||||
private readonly knex: knex.Knex; |
private knex: knex.Knex; |
||||||
|
private dbConfig: any; |
||||||
constructor() { |
|
||||||
this.knex = knex.default({ |
|
||||||
client: "mysql2", |
|
||||||
connection: { |
|
||||||
host: "localhost", |
|
||||||
user: "root", |
|
||||||
password: "password", |
|
||||||
database: "sakila" |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
get knexInstance(): knex.Knex { |
get knexInstance(): knex.Knex { |
||||||
return this.knex; |
return this.knex; |
||||||
} |
} |
||||||
|
|
||||||
|
// init metadb connection
|
||||||
|
async onModuleInit(): Promise<void> { |
||||||
|
this.dbConfig = await NcConfigFactory.make(); |
||||||
|
this.knex = knex.default({ ...this.dbConfig.meta.db, useNullAsDefault: true }); |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue