Skip to content

Instantly share code, notes, and snippets.

@burningTyger
Created February 12, 2018 20:48
Show Gist options
  • Save burningTyger/2356dc40946571d54a268ce1d2f36632 to your computer and use it in GitHub Desktop.
Save burningTyger/2356dc40946571d54a268ce1d2f36632 to your computer and use it in GitHub Desktop.
class BaseModel extends Model {
static get allRelations() {
return '[' + Object.keys(this.relationMappings).join(',') + ']';
}
}
//And then inherit your models from that instead of Model.
class Person extends BaseModel {
//...
}
//and then you can do this:
Person.query().eager(Person.allRelations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment