Skip to content

ModelEnum

Josh Wright edited this page Jan 14, 2021 · 4 revisions

ModelEnum

A protocol to which enums on Models should conform to. The enum will be modeled in the backing table by it's raw value.

public typealias ModelEnum = Codable & Parameter

Usage:

enum TaskPriority: Int, ModelEnum {
    case low, medium, high
}

struct Todo: Model {
    var id: Int?
    let name: String
    let isDone: Bool
    let priority: TaskPriority // Stored as `Int` in the database.
}
Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally