Skip to content

Protocol

AnyCodableProperty

Marks a property as participating in the Fields protocol’s (defaulted) implementation of Decodable and Encodable. This allows the property to encode and decode to and from representations other than storage in a database, and to act as a container if it contains any additional properties which also wish to participate. Just about every property type is codable.
protocol AnyCodableProperty : AnyProperty

Overview

Warning

The various relation property types sometimes behave somewhat oddly when encoded and/or decoded.

To Do

When corresponding parent and child properties on their respective models refer to each other, such as due to both relations being eager-loaded, both encoding and decoding will crash due to infinite recursion. At some point, look into a way to at least error out rather than crashing.

Topics

Instance Properties

  • skipPropertyEncoding
    Return true to skip encoding of this property. Defaults to false unless explicitly implemented.

Instance Methods

  • decode(from:)
    Decode an external representation and replace the property’s current data with the result.
  • encode(to:)
    Encode the property’s data to an external representation.

Relationships

Inherits From

Conforming Types