Open
Description
Feature proposal
- Firebase Component: Database
Mapping data between RTDB nodes and Swift structs has become a lot easier thanks to the addition of Codable support. However, the current implementation doesn't allow for automatically mapping a node's ID to an attribute on the respective Swift struct. To deal with this situation, developers add an extra field id
to their RTDB nodes, which might eventually result in a mismatch between this extra attribute and the actual node ID.
I propose to add a property wrapper similar to the one we use in Firestore (@DocumentID
) to
- map node IDs to the thusly annotated attribute on the Swift struct
- use
childByAutoId
to generate node IDs for new nodes if the attribute annotated with the property wrapper has anil
value
A possible name for the property wrapper might be @NodeID
, to match the @DocumentID
we use for Firestore.