FirebaseFirestoreSwift Framework Reference

DocumentID

@propertyWrapper
public struct DocumentID<Value: DocumentIDWrappable & Codable>:
  DocumentIDProtocol, Codable
extension DocumentID: Equatable where Value: Equatable
extension DocumentID: Hashable where Value: Hashable

A value that is populated in Codable objects with the DocumentReference of the current document by the Firestore.Decoder when a document is read.

If the field name used for this type conflicts with a read document field, an error is thrown. For example, if a custom object has a field firstName annotated with @DocumentID, and there is a property from the document named firstName as well, an error is thrown when you try to read the document.

When writing a Codable object containing an @DocumentID annotated field, its value is ignored. This allows you to read a document from one path and write it into another without adjusting the value here.

NOTE: Trying to encode/decode this type using encoders/decoders other than Firestore.Encoder leads to an error.

  • Declaration

    Swift

    public init(from documentReference: DocumentReference?) throws
  • Declaration

    Swift

    public init(from decoder: Decoder) throws
  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws