devsite/tools/jazzy/templates

FirebaseFirestore Framework Reference

ServerTimestamp

@propertyWrapper
public struct ServerTimestamp<Value>: Codable
  where Value: ServerTimestampWrappable & Codable
extension ServerTimestamp: Equatable where Value: Equatable
extension ServerTimestamp: Hashable where Value: Hashable

A property wrapper that marks an Optional<Timestamp> field to be populated with a server timestamp. If a Codable object being written contains a nil for an @ServerTimestamp-annotated field, it will be replaced with FieldValue.serverTimestamp() as it is sent.

Example:

struct CustomModel {
  @ServerTimestamp var ts: Timestamp?
}

Then writing CustomModel(ts: nil) will tell server to fill ts with current timestamp.

  • Declaration

    Swift

    public init(from decoder: Decoder) throws
  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws