Details
-
Improvement
-
Status: Backlog
-
Major - P3
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Currently, if you want to access a field in a nested document, you must do something like
let a = doc["a"]?.documentValue?["b"] |
It would be nice if users could instead do something like doc["a"]["b"].
However, this is not possible right now, as the subscript getter returns a BSON, and BSON objects are not subscriptable.
We could consider making BSON subscriptable. However, it's not clear what the behavior should be when a user tries to subscript something that isn't actually a document, for example, a String.
If we do implement this via subscript, analogous changes should be made to the dynamicMemberLookup behavior, to allow users to do doc.a.b etc.
Attachments
Issue Links
- related to
-
SWIFT-219 Add @dynamicMemberLookup to Document
-
- Closed
-