RandomExpression
public class RandomExpression : FunctionExpression, @unchecked SendableA RandomExpression is a FunctionExpression that generates a random floating-point
number between 0.0 (inclusive) and 1.0 (exclusive).
This expression is useful when you need to introduce a random value into a pipeline, for example, to randomly sample a subset of documents.
Example of using RandomExpression to sample documents:
// Create a query to sample approximately 10% of the documents in a collection
firestore.pipeline()
.collection("users")
.where(rand().lessThan(0.1))
-
Creates a new
RandomExpressionthat generates a random number.Declaration
Swift
public init()