DEV Community

Discussion on: Discover AdonisJS : Model Factories and Edge Template

Collapse
 
kirschd profile image
kirschd

Hi Eric, your tutorial series are great - many on topics I am pursuing. Thanks!

I followed this one and get an error when calling the PostsFactory to seed the db from the create-posts.

ReferenceError
PostFactory is not defined - on start/routes.ts

I made sure to follow steps and double checked - it seems that PostsFactory is not available to the scope of the running app - is this something that the ioc should be taking care of?
Do I need to explicitly import PostsFactory anywhere?

Thanks

Collapse
 
kirschd profile image
kirschd

Not that familiar with ioc on Adonis so I just did import explicitly at routes.ts and this worked for me:

import Route from '@ioc:Adonis/Core/Route'
import {PostFactory} from 'Database/Factories/index'

Collapse
 
waheedk53694017 profile image
Waheed khan

Hi , kirschd . I have a little question for you.
if we dont want to use migrations and just want to map model with databse then how will we do that ? if you have a code in git hub repo then please give me the link