Skip to content

Commit

Permalink
fix: attach adapter to the base model
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 23, 2019
1 parent 55bb5c5 commit 551a7db
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion providers/DatabaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
*/

import { IocContract } from '@adonisjs/fold'

import { Database } from '../src/Database'
import { BaseModel } from '../src/Orm/BaseModel'
import { Adapter } from '../src/Orm/Adapter'
import { column } from '../src/Orm/Decorators'
import { BaseModel } from '../src/Orm/BaseModel'

export default class DatabaseServiceProvider {
constructor (protected $container: IocContract) {
Expand All @@ -28,6 +30,12 @@ export default class DatabaseServiceProvider {
})

this.$container.singleton('Adonis/Lucid/Orm', () => {
/**
* Attaching adapter to the base model. Each model is allowed to define
* a different adapter.
*/
BaseModel.$adapter = new Adapter(this.$container.use('Adonis/Lucid/Database'))

return {
BaseModel,
column,
Expand Down

0 comments on commit 551a7db

Please sign in to comment.