EntityBinding

public protocol EntityBinding

The code generator generates concrete instances of EntityBinding objects that perform the actual work of transferring database values into your Swift objects and extracting them for writing out.

You usually don’t have to deal with this class.

  • The type this binding serves as an adapter for.

    Declaration

    Swift

    associatedtype EntityType : Entity, EntityInspectable
  • The type of the ‘id’ property in EntityType.

    Declaration

    Swift

    associatedtype IdType : IdBase
  • Used by Box to create new EntityBinding adapter instances.

    Declaration

    Swift

    init()
  • Writes the given entity’s value to the given PropertyCollector, assigning it the given ID. entityId must not be 0.

    Declaration

    Swift

    func collect(fromEntity entity: EntityType, id entityId: Id, propertyCollector: PropertyCollector, store: Store)
  • postPut(fromEntity:id:store:) Default implementation

    The collected entity has been put and now it’s time to attach and put all relations, if this entity is new.

    Default Implementation

    The collected entity has been put and now it’s time to attach and put all relations, if this entity is new.

    Declaration

    Swift

    func postPut(fromEntity entity: EntityType, id entityId: Id, store: Store)
  • Creates a new entity based on data from the given EntityReader. Returns: The new entity.

    Declaration

    Swift

    func createEntity(entityReader: EntityReader, store: Store) -> EntityType
  • For class types, this is used to write the new entity ID back to the entity when they are first put into a box. Note that this function only works on classes, it will quietly do nothing when used on a struct.

    Declaration

    Swift

    func setEntityIdUnlessStruct(of entity: EntityType, to entityId: Id)
  • Used to read the ID of an entity.

    Declaration

    Swift

    func entityId(of entity: EntityType) -> Id
  • setToOneRelation(_:of:to:) Default implementation

    Modify a ToOne relation using its property ID, used when modifying ToOne backlinks.

    Default Implementation

    Modify a ToOne relation using its property ID, used when modifying ToOne backlinks.

    Declaration

    Swift

    func setToOneRelation(_ propertyId: obx_schema_id, of entity: EntityType, to entityId: Id?)