-
Type:
Improvement
-
Resolution: Works as Designed
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Kotlin
-
None
-
None
-
Java Drivers
-
None
-
None
-
None
-
None
-
None
-
None
I
In the Kotlin driver extensions, we can use data class KProperties to create Filters. For example given these models as data classes:
data class Movie(val movieName: String, releaseDate: LocalDate, rating: String) data class MovieReview(val movie: Movie, val rating: Double, val review: String, val reviewerName: String)
If I wanted to query a movie review by its rating I could simply write:
MovieReview::rating gte .8
but if I wanted to query a MovieReview by the movie name I cannot currently do:
MovieReview::movie.movieName eq "Mobile Suit Gundam: Char's Counterattack"
I believe KMongo has the ability to do this by overloading the / operator so I could query like:
MovieReview::movie / Movie::movieName eq "Mobile Suit Gundam: Char's Counterattack"
I think a similar feature should be included in the kotlin driver extensions to avoid have to switch between query methods. The examples for the queries in the documentation uses overly simplistic Models which is good to start but it shouldn't be explicitly stated that you cannot query nested properties via data classes.