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

Support missing bson field in documents

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Scala
    • None
    • Hide

      Something like:

      If an bson array field is missing from the document, it will be populated as an empty collection at runtime.

      Show
      Something like: If an bson array field is missing from the document, it will be populated as an empty collection at runtime.

    Description

      Goal: Be able to deserialize documents where

      • field is missing
      • field type is a child of `Iterable`

      to ease changes in models without having to run scripts or write custom codecs.

       

      Now, this won't work,
      but we could expect that `metadata` and `aliases` are considered as empty, or at least having a setting in the client to enable it.

      {
        "name": "John Doe"
      }
      

       

       
      case class Person(name: String, aliases: Set[String], metadata: Map[String, String])
      
      

      Attachments

        Activity

          People

            ross@mongodb.com Ross Lawley
            gael.ferrachat@newsbridge.io Gaël Ferrachat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: