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.

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

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