hapipal / schwifty

A model layer for hapi integrating Objection ORM
MIT License
73 stars 10 forks source link

$relatedQuery #64

Closed rickysullivan closed 5 years ago

rickysullivan commented 5 years ago

What am I doing wrong that I can't run .$relatedQuery('clients') on my DataCentre model?

I had no issues with objection.js before trying out schwifty.

devinivy commented 5 years ago

I'm not sure—you'll have to provide some more info about what kind of errors or unexpected output you're seeing. Any context you can share would also be useful, e.g. some runnable code. We make queries like this all the time without issue, so I fully expect it's just something small!

wswoodruff commented 5 years ago

Also checking to make sure you're using $relatedQuery on an instance of your model instead of the class. Dollar sign methods are for instances, remove the $ to use on the class like DataCentre.relatedQuery('clients')

rickysullivan commented 5 years ago

You're right. It does work as expected. Turns out I needed to use .eager('clients') because of the relation. I'm sorry for the troubles.

devinivy commented 5 years ago

Glad you got it sorted out!