Constant
public struct Constant : Expression, BridgeWrapper, @unchecked SendableA Constant is an Expression that represents a fixed, literal value within a Firestore
pipeline.
Constants are used to introduce literal values into a query, which can be useful for:
- Comparing a field to a specific value in a
whereclause. - Adding new fields with fixed values using
addFields. - Providing literal arguments to functions like
sumoraverage.
Example of using a Constant to add a new field:
// Add a new field "source" with the value "manual" to each document
firestore.pipeline()
.collection("entries")
.addFields([
Constant("manual").as("source")
])
-
Creates a new
Constantexpression from an integer literal.Declaration
Swift
public init(_ value: Int)Parameters
valueThe integer value.
-
Creates a new
Constantexpression from a double-precision floating-point literal.Declaration
Swift
public init(_ value: Double)Parameters
valueThe double value.
-
Creates a new
Constantexpression from a string literal.Declaration
Swift
public init(_ value: String)Parameters
valueThe string value.
-
Creates a new
Constantexpression from a boolean literal.Declaration
Swift
public init(_ value: Bool)Parameters
valueThe boolean value.
-
Creates a new
Constantexpression from aData(bytes) literal.Declaration
Swift
public init(_ value: Data)Parameters
valueThe
Datavalue. -
Creates a new
Constantexpression from aTimestampliteral.Declaration
Swift
public init(_ value: Timestamp)Parameters
valueThe
Timestampvalue. -
Creates a new
Constantexpression from aDateliteral.The
Datewill be converted to aTimestampinternally.Declaration
Swift
public init(_ value: Date)Parameters
valueThe
Datevalue. -
Creates a new
Constantexpression from aDocumentReferenceliteral.Declaration
Swift
public init(_ value: DocumentReference)Parameters
valueThe
DocumentReferencevalue. -
Creates a new
Constantexpression from aVectorValueliteral.Declaration
Swift
public init(_ value: VectorValue)Parameters
valueThe
VectorValuevalue. -
A
Constantrepresenting anilvalue.Declaration
Swift
public static let `nil`: Constant