Skip to content

Instance Method

join(children:method:)

This will join a foreign table based on a @Children relation
@discardableResult func join<To>(children: KeyPath<Model, ChildrenProperty<Model, To>>, method: DatabaseQuery.Join.Method = .inner) -> Self where To : Model

Parameters

children

The ChildrenProperty to join

method

The method to use. The default is an inner join

Return Value

A new QueryBuilder

Discussion

This will not decode the joined data, but can be used in order to filter.

Star.query(on: db)
    .join(children: \.$planets)
    .filter(Planet.self, \Planet.$name == "Earth")