I have changed both files as far as commas and semicolons, both of which have been driving eslint crazy. Nothing seems to appease it within factory.js especially, but the odd error messages that I am getting below make me think this may be something else. Anyone have any experience with this?
UserSeeder.js
const Factory = use('Factory');
const Database = use('Database');
class UserSeeder {
async run () {
const user = await Factory
.model('App/Models/User')
.create()
const users = await Database.table('users');
console.log(users);
}
}
module.exports = UserSeeder;
factory.js
const Factory = use('Factory');
const Hash = use('Hash');
Factory.blueprint('App/Models/User', () => {
return {
username: 'test',
email: 'test@test.com',
password: await Hash.make('test'),
}
});
And the lovely and informative error message:
SyntaxError: Unexpected identifier
1 _preLoadFiles.forEach
D:\Source\VuePractice\intro-to-vuetify-with-
adonis\server\node_modules\@adonisjs\ignitor\src\Ignitor\index.js:375
2 Ignitor._loadPreLoadFiles
D:\Source\VuePractice\intro-to-vuetify-with-
adonis\server\node_modules\@adonisjs\ignitor\src\Ignitor\index.js:367
3 Ignitor.fire
D:\Source\VuePractice\intro-to-vuetify-with-
adonis\server\node_modules\@adonisjs\ignitor\src\Ignitor\index.js:760
答案 0 :(得分:1)
您的代码中存在的问题是您在await
的工厂中使用关键字App/Models/User
,而回调不是async
。
它必须是:
const Hash = use('Hash')
const Factory = use('Factory')
Factory.blueprint('App/Models/User', async () => {
return {
username: 'test',
email: 'test@test.com',
password: await Hash.make('test'),
}
})
答案 1 :(得分:0)