DatabaseColumnDecodingStrategy

DatabaseColumnDecodingStrategy specifies how FetchableRecord types that also adopt the standard Decodable protocol look for the database columns that match their coding keys.

For example:

struct Player: FetchableRecord, Decodable {
    static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase

    // Decoded from the player_id column
    var playerID: Int
}
  • A key decoding strategy that doesn’t change key names during decoding.

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

  • A key decoding strategy defined by the closure you supply.