DatabaseColumnDecodingStrategy
public enum 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.
Declaration
Swift
case useDefaultKeys
-
A key decoding strategy that converts snake-case keys to camel-case keys.
Declaration
Swift
case convertFromSnakeCase
-
A key decoding strategy defined by the closure you supply.
Declaration
Swift
case custom((String) -> CodingKey)