From 60d085d4488fe12cc5dbf2938cc06a5983a64a4f Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Wed, 20 Sep 2023 21:51:16 +0200 Subject: [PATCH] fix(provider): properly define the adapter for the base model --- providers/database_provider.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/providers/database_provider.ts b/providers/database_provider.ts index 7f096e16..37d6d8fc 100644 --- a/providers/database_provider.ts +++ b/providers/database_provider.ts @@ -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' { @@ -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) + } }