Skip to content

Commit

Permalink
fix(provider): properly define the adapter for the base model
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz committed Sep 20, 2023
1 parent 5edf520 commit 60d085d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions providers/database_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type { ApplicationService } from '@adonisjs/core/types'

import { Database } from '../src/database/main.js'
import { QueryClient } from '../src/query_client/index.js'
import { BaseModel } from '../src/orm/base_model/index.js'
import { Adapter } from '../src/orm/adapter/index.js'
import type { DatabaseConfig } from '../src/types/database.js'

declare module '@adonisjs/core/types' {
Expand Down Expand Up @@ -40,4 +42,9 @@ export default class DatabaseServiceProvider {

this.app.container.alias('lucid.db', Database)
}

async boot() {
const db = await this.app.container.make('lucid.db')
BaseModel.$adapter = new Adapter(db)
}
}

0 comments on commit 60d085d

Please sign in to comment.