[JAVA-3552] Allow Mongo collection reads into a Scala case class to use the class member default value for a missing collection field Created: 27/Jun/18  Updated: 30/Mar/22

Status: Backlog
Project: Java Driver
Component/s: Scala
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Edem Nsefik Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 16.04



 Description   

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())


Generated at Thu Feb 08 08:59:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.