kotlinx.serialization missing array query operator

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Kotlin
    • None
    • Java Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      The kotlinx.serialization DSL (Person::name eq "John Doe") does not provide a method to query an array.

      Person::hobbies eq "coding" // does not compile since hobbies is a List<String>

      There are two options to solve the problem:

      1. Write an additional extension function such as 

      infix fun <T> KProperty<List<T>>.eq(value: T): Bson = com.mongodb.client.model.Filters.eq(path(), value) 

      This would be closer to the MongoDB query syntax.

      2. Introduce a contains/in operator so you can write

      Person::hobbies contains "coding"
      

      and/or

      "coding" in Person::hobbies

      which would be more Kotlin-idiomatic

       

            Assignee:
            Unassigned
            Reporter:
            Richard Schielek
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: