Skip to content

Instance Subscript

subscript(dynamicMember:)

An @dynamicMemberLookup subscript which access to the projected values of individual properties of self.model without having to actually add .model to each usage. The AliasedField helper type further ensures that the alias propagates correctly through further helpers and subsysems, most particularly .with() closures in a query for eager- loading.
subscript<Field>(dynamicMember keyPath: KeyPath<Self.Model, Field>) -> AliasedField<Self, Field> where Field : Property, Self.Model == Field.Model { get }

Overview

The presence of subscript(dynamicMember:) and this subscript together enables nearly transparent use of a ModelAlias type as if it were the underlying Model type.

Example:

let alias = HomeTeam()
print(alias.$id.exists) // false