Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-191

Add a way to provide a default value when looking up a key in a Document

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 0.0.8
    • None

    Description

      In many languages (including Swift) there is a way to provide a default value to use for a key that isn't present in a dictionary. 

      The Swift-y way incorporates the value into the subscript getter:

      let value = doc["x", default: 0]

      See documentation here.

      We should consider supporting this on Documents. 

      Note we will need to think carefully about behavior when there are null values in documents.

      Attachments

        Issue Links

          Activity

            People

              may.hoque@mongodb.com May Hoque
              kaitlin.mahar@mongodb.com Kaitlin Mahar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: