addons load relation throw error when the foreign key is null #3376
farshadfahimi
started this conversation in
Ideas
Replies: 1 comment
-
You can simply avoid running the query by checking for the let user: User | null = order.userId ? await order.related('user').query().debug(true).first() : null
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have simple query like below
let user: User | null = await order.related('user').query().debug(true).first()
some times the
usersId
is null in my query and the above query on execute got below errorCannot preload \"user\", value of \"Order.usersId\" is undefined
I think it's not a good Idea to thorw an error it's better to return null
Beta Was this translation helpful? Give feedback.
All reactions