Last active
April 5, 2020 19:29
-
-
Save dievardump/f270480f2f98996ce1f5ca49166e532f to your computer and use it in GitHub Desktop.
Adonis v5 Provider exemple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IocContract } from '@adonisjs/fold' | |
import PostsLoader from './load/Posts' | |
export default class ETLProvider { | |
constructor (protected $container: IocContract) { | |
} | |
public register (): void { | |
// register bindings | |
this.$container.singleton('ETL/Loader/Posts', () => { | |
const Track = this.$container.use('App/Models/Track').default | |
const User = this.$container.use('App/Models/User').default | |
const Post = this.$container.use('App/Models/Post').default | |
const Helpers = this.$container.use('App/helpers').default | |
return new PostsLoader(Track, User, Post, Helpers) | |
}) | |
} | |
public async boot () { | |
// optionally do some initial setup | |
const loader = this.$container.use('ETL/Loader/Posts') | |
await loader.init() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment