I have a relationship that is structured like:
Book {
id: UUID
author: Author
}
Author {
id: UUID
genre: Genre
}
Genre {
id: UUID
name: String
}
I want to be able to query for books that have authors that have a specialize in a specific genre.
I want to do something like:
let query = Book.query(on: db)
.with(\.$author) { author in
author.with(\Author.$genre)
}
.filter(\Book.$author.$genre.$name, .equal, "Mystery")
But I am getting issues with accessing the genre field from the author.
If I change it to:
.filter(\Book.author.$genre.$name, .equal, "Mystery")
I get an error where it says author wasn't eager loaded.