You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model with a relation that's optional, however when I use $relatedQuery to get the relation, the return type is not optional. I put together a small project to demonstrate!
Snippet from project:
const Example = async () => {
const customer = await Customer.query().findById("123").throwIfNotFound();
/**
* The program relation on customer is an optional relation. I would expect this to be returned from $relatedQuery
* as optional, but the typing is just Program
*/
const program = await customer.$relatedQuery("program");
console.log(program.id);
}
I have a model with a relation that's optional, however when I use $relatedQuery to get the relation, the return type is not optional. I put together a small project to demonstrate!
Snippet from project:
Example project:
https://github.com/ryan-gray-db/objection-relation
The text was updated successfully, but these errors were encountered: