r/adonisjs • u/Capable_Square7319 • Oct 27 '26
Beginner Coder: Stuck with a db error
Hi,
I'm working on an adonisjs project. l've ran into an error
My project is on github:
https://github.com/Ajaz754/adonisjs-project-22-.git
The error is in file 'database/seeders/ product_seeder.ts' Line 10
The error is:
Object literal may only specify known properties, and 'userld' does not exist in type
'OneOrMany<Partial<ModelAttributes<Product>>>.
Adding 'userId' field to the product schema and rerunnning migration did not fix the issue.
I think it may have something to do with this (something I tried in the REPL):
> (js) const user = await models.user.find(1)
Uncaught SyntaxError: Identifier 'user' has already been declared
> (js) user.id
Uncaught ReferenceError: user is not defined
> (js)
I don't understand. Please correct me if I'm wrong but it says 'user' already exists but when I try to use it, it says its undefined?
Any help would be much appreciated
TIA
3
u/Aceventuri Oct 27 '26
You have a mix of user.id, user_id and userId in your migrations. Make them all snake case. Db field names should be snakecase and adonis will autoconvert to camelCase in the schema.
2
u/elconcarne Oct 27 '26
I don’t see userId in the product table in the schema
2
u/elconcarne Oct 27 '26
Did you run the migration?