Skip to content

Instance Method

join(from:child:method:)

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

Parameters

model

The Model to join from

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")