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

Add @dynamicMemberLookup to Document

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 0.0.8
    • None

    Description

      Swift 4.2 introduces the @dynamicMemberLookup attribute. Basically, this is just syntactic sugar, allowing you to use dot notation to look up arbitrary properties on a type.

      A natural place for us to use this is on documents. This will allow users to do things like the following:

      var doc: Document = ["a": 1, "b": 2]
      print(doc.a) // prints 1
      print(doc.x) // prints nil
      print(doc.b) // prints 2

      Implementing this will require adding the attribute to Document, and adding a new subscript(dynamicMember: ) method that behaves identically to our existing subscript getter. 

      Attachments

        Issue Links

          Activity

            People

              patrick.freed@mongodb.com Patrick Freed
              kaitlin.mahar@mongodb.com Kaitlin Mahar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: