Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5803

Allow querying nested properties via data classes

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Kotlin
    • None
    • None
    • Java Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None