Enumerations

The following enumerations are available globally.

Database events

Date functions

DatabaseDateEncodingStrategy

  • DatabaseDateEncodingStrategy specifies how EncodableRecord types that also adopt the standard Encodable protocol encode their Date properties.

    For example:

    struct Player: EncodableRecord, Encodable {
        static let databaseDateEncodingStrategy = DatabaseDateEncodingStrategy.timeIntervalSince1970
    
        var name: String
        var registrationDate: Date // encoded as an epoch timestamp
    }
    
    See more

DatabaseUUIDEncodingStrategy

  • DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that also adopt the standard Encodable protocol encode their UUID properties.

    For example:

    struct Player: EncodableProtocol, Encodable {
        static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
    
        // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
        var uuid: UUID
    }
    
    See more

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
    }
    
    See more

DatabaseDateDecodingStrategy

  • DatabaseDateDecodingStrategy specifies how FetchableRecord types that also adopt the standard Decodable protocol decode their Date properties.

    For example:

    struct Player: FetchableRecord, Decodable {
        static let databaseDateDecodingStrategy = DatabaseDateDecodingStrategy.timeIntervalSince1970
    
        var name: String
        var registrationDate: Date // decoded from epoch timestamp
    }
    
    See more

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
    }
    
    See more

Existence Check