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

Support BsonIgnore annotation for Scala case classes

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.2.0
    • None
    • Scala
    • None

    Description

      Goal: Add a way to ignore BSON serialization of a case class field.

      Context**: We don't want to store into MongoDB some case class fields (eg. computed from other sources or used for binary serialization). But we don't want (sometimes we can't) wrap them into Option (eg. to avoid things like Option[Seq[T]]).

       

      I saw Java Driver has a BsonIgnore annotation, could it be possible to implement it ? It can cause issues for types that have no default constructor or default value but it could be prerequisite ?

      For example

      case class Picture(
                          height: Int,
                          width: Int,
                          @BsonIgnore
                          metadata: Seq[Metadata] = Seq.empty
                        )

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: