hapipal / schwifty

A model layer for hapi integrating Objection ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$relatedQuery

rickysullivan opened this issue · comments

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.

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!

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')

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.

Glad you got it sorted out!