DatabaseColumnEncodingStrategy

public enum DatabaseColumnEncodingStrategy

DatabaseColumnEncodingStrategy specifies how EncodableRecord types that also adopt the standard Encodable protocol encode their coding keys into database columns.

For example:

struct Player: EncodableProtocol, Encodable {
    static let databaseColumnEncodingStrategy = DatabaseColumnEncodingStrategy.convertToSnakeCase

    // Encoded in the player_id column
    var playerID: String
}
  • A key encoding strategy that doesn’t change key names during encoding.

    Declaration

    Swift

    case useDefaultKeys
  • A key encoding strategy that converts camel-case keys to snake-case keys.

    Declaration

    Swift

    case convertToSnakeCase
  • A key encoding strategy defined by the closure you supply.

    Declaration

    Swift

    case custom((CodingKey) -> String)