November 2018
Intermediate to advanced
404 pages
10h 16m
English
You can use either struct or class to conform to Model. Since struct is value-typed, a new copy of the struct model will be returned each time you query the database. Class is reference-typed so there won't be a new copy created when the class model is returned as the result for querying the database:
import FluentPostgreSQLimport Vaporfinal class JournalEntry: PostgreSQLModel { var id: Int? var title: String var content: String init(id: Int? = nil, title: String, content: String) { self.id = id self.title = title self.content = content }}
The final modifier prevents anyone from subclassing your model.
var id: Int?
Fluent uses id for the internal indexing ...
Read now
Unlock full access