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() |
||||
|
||||
@Injectable() |
||||
export class Connection { |
||||
private readonly knex: knex.Knex; |
||||
|
||||
constructor() { |
||||
this.knex = knex.default({ |
||||
client: "mysql2", |
||||
connection: { |
||||
host: "localhost", |
||||
user: "root", |
||||
password: "password", |
||||
database: "sakila" |
||||
} |
||||
}); |
||||
} |
||||
export class Connection implements OnModuleInit { |
||||
private knex: knex.Knex; |
||||
private dbConfig: any; |
||||
|
||||
get knexInstance(): knex.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