Different ways to retrieve Parent-Child and Sibling relationships?

By chapter 17, Acronym has a parent relationship to User and a sibling relationship to Category. Fluent.ParentProperty and Fluent.SiblingsProperty both conform to Relation which is where get(reload:on:) is implemented.

(Sorry, just Rubber Duck’ing here…)

Is there a difference between myAcronym.$categories.get(on: req.db) and myAcronym.$categories.query(on: req.db).all()?

Essentially nope it’s the same under the hood, with a bit of optimisation if they’ve already been loaded.

.get(on:) calls through to load(on:) if they haven’t been eager loaded already and that calls through to all() and sets the eager loaded value

1 Like