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

Allow Mongo collection reads into a Scala case class to use the class member default value for a missing collection field

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Scala
    • None
    • Environment:
      Ubuntu 16.04

      Currently  with  2.2.1 and higher, a case class that is registered can denote possible missing fields as Option[field]. Sometimes we have default values on case classes and it would be good if a collection can be read into a case class so the missing fields are replaced by the defaults

      for example: 

      case class Reg (name: String, mark: Int, loc: String, date: Date = new Date())

      collection Registration {"name": "David", "mark": 75, "loc": "The Gragg" }

      I would like the collection Registration to be read into Reg as

      Reg("David", 75, "The Gragg", new Date())

            Assignee:
            Unassigned Unassigned
            Reporter:
            ensefik Edem Nsefik
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: