Skip to content

Getters

Jeff Hurray edited this page Apr 25, 2016 · 2 revisions

All models conforming to SQLiteModel have a static method called get which will return the value associated with a column.

let title = myMovie.get(Movie.Title)

You can also use the => operator for some syntactic sugar

let title = myMovie => Movie.Title

All non-relationship gets are retrieved from a cache and are O(1) operations.

You can add a little more syntactic sugar to your models with dynamic variables:

extension Movie {
    
    var title: String {
        get {
            return self => Movie.Title
        }
        set {
            self <| Movie.Title |> newValue
        }
    }
}

Clone this wiki locally