Skip to content

Instance Method

join(child:method:)

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

Parameters

child

The ChildProperty 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.

Planet.query(on: db)
    .join(child: \.$governor)
    .filter(Governor.self, \Governor.$name == "John Doe")