__EntityRelatable

public protocol __EntityRelatable

Protocol used in generated code to provide an ID getter (wrapped as EntityId<T>) of an object.

The code generator will make your entity types conform to this and implement the requirements.

Currently only used to check if the ID is 0 in Box.remove and the LazyProxyRelation.State constructor. The type information (T of EntityId<T>) is unused. Also note that IDs no longer have to implement EntityId.

For example:

class Person: __EntityRelatable {
    typealias EntityType = Person
    var _id: EntityId<Person>  {
        return EntityId<Person>(self.id.value)
    }
}
  • Placeholder for the entity type to use with the _id getter.

    Declaration

    Swift

    associatedtype EntityType : Entity
  • _id

    Used to get the ID value of an object of the associated entity type.

    Declaration

    Swift

    var _id: EntityId<EntityType> { get }