devsite/tools/jazzy/templates

FirebaseDatabase Framework Reference

ServerTimestamp

@propertyWrapper
public struct ServerTimestamp : Codable, Equatable, Hashable

A property wrapper that marks an Optional<Date> 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 ServerValue.timestamp() as it is sent.

Example:

struct CustomModel {
  @ServerTimestamp var ts: Date?
}

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