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

How do I build a custom query if all I have is a Table? #36

Open
Morpheu5 opened this issue May 5, 2018 · 2 comments
Open

How do I build a custom query if all I have is a Table? #36

Morpheu5 opened this issue May 5, 2018 · 2 comments
Labels
question Further information is requested

Comments

@Morpheu5
Copy link

Morpheu5 commented May 5, 2018

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? :)

@EnriqueL8
Copy link
Contributor

EnriqueL8 commented May 9, 2018

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

@kilnerm kilnerm added the question Further information is requested label Nov 19, 2018
@kilnerm
Copy link
Contributor

kilnerm commented Nov 19, 2018

@Morpheu5, Do you need any further assistance with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants