Swift-Kuery-ORM
Swift-Kuery-ORM copied to clipboard
How do I build a custom query if all I have is a Table?
With reference to #35, I am trying to build a series of queries to do my own validation before saving/updating my models. The docs suggest to retrieve the table like this
do {
let table = Grade.getTable()
} catch {
// Error
}
and then use it to build a plain old Query
using Swift-Kuery. However, getTable()
returns a Table
, which obviously has none of the keys of Grade
, because it is not a Table
).
Any pointers? :)
Hey @Morpheu5 , an idea would be to extend your Grade
Model - like this:
extension Grade {
func save(....) {
// Validation
// Create Query with Table
// Execute Query
}
}
The extension in Grade
will overwrite the extension of Model
Have a look at the Model.swift
code for reference. Let me know if that solves the problem
@Morpheu5, Do you need any further assistance with this issue?