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

Common API for requests and associations derivation #347

Merged
merged 2 commits into from
May 5, 2018

Conversation

groue
Copy link
Owner

@groue groue commented May 4, 2018

This PR introduces DerivableRequest, a protocol that lets you enrich the query interface API. Write one extension, derive both requests and associations:

// One extension...
extension DerivableRequest where RowDecoder == Author {
    func filter(country: String) -> Self {
        return filter(Column("country") == country)
    }
}

// Apply to a request
let frenchAuthors = Author.all().filter(country: "FR")

// Apply to an association
let frenchBooks = Book.joining(required: Book.author.filter(country: "FR"))

@groue groue added this to the GRDB 3.0 milestone May 4, 2018
@groue groue mentioned this pull request May 4, 2018
29 tasks
@groue groue merged commit 310c263 into GRDB3 May 5, 2018
@groue groue deleted the GRDB3-DerivableRequest branch May 5, 2018 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant