Skip to content

Commit

Permalink
fix: export Database const from typings
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jan 12, 2020
1 parent b3add70 commit b9b41d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
14 changes: 9 additions & 5 deletions adonis-typings/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
/// <reference path="./querybuilder.ts" />

declare module '@ioc:Adonis/Lucid/Database' {
import knex from 'knex'
import { Pool } from 'tarn'
import * as knex from 'knex'
import { EventEmitter } from 'events'
import { Dictionary } from 'ts-essentials'
import { ProfilerRowContract, ProfilerContract } from '@poppinss/profiler'
Expand Down Expand Up @@ -226,7 +226,6 @@ declare module '@ioc:Adonis/Lucid/Database' {
flags?: string,
ssl?: any,
}

export type MysqlConfigContract = SharedConfigNode & {
client: 'mysql',
version?: string,
Expand Down Expand Up @@ -312,7 +311,6 @@ declare module '@ioc:Adonis/Lucid/Database' {
maxRows?: number,
oracleClientVersion?: number,
}

export type OracleConfigContract = SharedConfigNode & {
client: 'oracledb',
connection?: SharedConnectionNode & OracleConnectionNode,
Expand Down Expand Up @@ -342,7 +340,6 @@ declare module '@ioc:Adonis/Lucid/Database' {
requestTimeout?: number,
parseJSON?: boolean,
}

export type MssqlConfigContract = SharedConfigNode & {
client: 'mssql',
version?: string,
Expand Down Expand Up @@ -515,6 +512,10 @@ declare module '@ioc:Adonis/Lucid/Database' {
getClient (mode?: 'write' | 'read'): QueryClientContract,
}

/**
* Options when retrieving new query client from the database
* query builder
*/
type DatabaseClientOptions = Partial<{
mode: 'read' | 'write',
profiler: ProfilerRowContract | ProfilerContract,
Expand Down Expand Up @@ -545,7 +546,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Get query client for a given connection. Optionally one can also define
* the mode of the connection and profiler row
*/
connection (connectionName: string, options?: DatabaseClientOptions): QueryClientContract
connection (connectionName?: string, options?: DatabaseClientOptions): QueryClientContract

/**
* Get query builder instance for a given connection.
Expand Down Expand Up @@ -597,4 +598,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
*/
transaction (): Promise<TransactionClientContract>
}

const Database: DatabaseContract
export default Database
}
8 changes: 0 additions & 8 deletions adonis-typings/querybuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ declare module '@ioc:Adonis/Lucid/DatabaseQueryBuilder' {
import { Dictionary } from 'ts-essentials'
import { ProfilerRowContract, ProfilerContract } from '@poppinss/profiler'

/**
* The types for values for the aggregates. We need this coz of
* the history with bigints in Javascript
*/
export interface AggregatesRegistry {
Count: number,
}

/**
* Get one or many of a generic
*/
Expand Down
2 changes: 1 addition & 1 deletion providers/DatabaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DatabaseServiceProvider {
* Register database binding
*/
public register () {
this.$container.singleton('Adonis/Addons/Database', () => {
this.$container.singleton('Adonis/Lucid/Database', () => {
const config = this.$container.use('Adonis/Core/Config').get('database', {})
const Logger = this.$container.use('Adonis/Core/Logger')
const Profiler = this.$container.use('Adonis/Core/Profiler')
Expand Down

0 comments on commit b9b41d4

Please sign in to comment.