Return fkey fields as default in fetch()


I notice that fetch() doesn’t return fkey reference fields as default. I had to manually add them via include in the FetchSpec.

Is there an annotation I can put on the fkey reference field, so fetch will display it as default?


You can find db annotation by doing c3ShowType(Ann.Db)

In this case, you can add an include annotation.

entity type SomeType {

  fkeys: [OtherType] (parent)


Now whenever you do SomeType.fetch, fkeys field will be included.


Thanks! This is great.

I tried this. This returns every field from the referenced object, which is potentially huge. Is there a way to just include the id of the referenced objects? I tried @db(include='') , it doesn’t seem to work


try @db(include='id')

#5 Keep in mind that they don’t come back unless explicitly requested because it requires extra querying. You should only do this if absolutely necessary. Our policy/philosophy is that EVERY fetch should include the fields that it requires to avoid wasting db/cpu/memory/io resources. So I don’t see any particular reason why you should need to do this.