Skip to content

Instance Method

join(parent:method:)

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

Parameters

parent

The OptionalParentProperty 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(parent: \.$star)
    .filter(Star.self, \Star.$name == "Sol")