Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Enum demo #3

Open
iOSleep opened this issue Sep 29, 2022 · 1 comment
Open

add Enum demo #3

iOSleep opened this issue Sep 29, 2022 · 1 comment
Labels

Comments

@iOSleep
Copy link

iOSleep commented Sep 29, 2022

enum CompassPoint: Int {
    case none
    case north
    case south
    case east
    case west
}

extension CompassPoint : Bindable, ConstructableFromSQLiteValue {
    init(sqliteValue: SQLiteORM.SQLiteValue) {
        self = CompassPoint(rawValue: sqliteValue.integer) ?? .none
    }
    
    func bind(to binder: Binder) -> Int32 {
        return binder.bindInt(value: self.rawValue)
    }
    
    public static func sqliteTypeName() -> String {
        return "INTEGER"
    }
    
}

🤔

@fnc12
Copy link
Owner

fnc12 commented Sep 29, 2022

good idea. Thanks. I'll add a full example

@fnc12 fnc12 added the example label Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants