I have a class that adopts both TableRecord
and FetchableRecord
. I am taging advantage of the automagic query generation provided by GRDB, and I only provide the table name because it doesn't match the class name. However now i want to add stored properties that are only used at run-time, and i don't want GRDB to try to fetch those autmatically. Can i exclude certain variables from the query?
Here is my code:
class Question: Identifiable, Codable, TableRecord, FetchableRecord {
static var databaseTableName = "questions"
var id: Int?
var category: Int?
var code: String?
var ...
var ...
var ...
var ...
var selectedAnswer: Int? // This is only used at run-time and not present in the database.
}
I found this:
static var databaseSelection = [Column("id"), Column("category"), Column("code"), ...]
But that requires me to manually specify all the columns that i want it to fetch. Can i do the opposite, and just exclude one column (selectedAnswer)?
Basically what im looking for is something like this:
static var excludedVariables = ["selectedAnswer"]
I had a read through the documentation and couldn't find anything, but i don't know GRDB so i could have missed something.