Visitar URL original
FirebaseFirestore Framework Reference

FirebaseFirestore Framework Reference

Rank

public class Rank : WindowFunction, @unchecked Sendable

[Public Preview] Returns the rank of each document within its partition according to the window's sort order. Documents with equal sort values receive the same rank, and the following rank is skipped. The window must specify exactly one sort ordering.

Example usage:

firestore.pipeline()
  .collection("sales")
  .addWindowFields(
    window: .partition(["product"]).sort(Field("salesPrice").descending()),
    fields: [
      Rank().as("topSalesRank")
    ]
  )

Warning

Window Functions SDK features are in preview until the backend feature launches. Look for the launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

  • Initializes a new Rank window function.

    Declaration

    Swift

    public init()