1818  @_exported   import  FirebaseFirestoreInternal
1919#endif // SWIFT_PACKAGE 
2020
21+ ///
22+ /// A `Constant` is an `Expression` that represents a fixed, literal value within a Firestore
23+ /// pipeline.
24+ ///
25+ /// `Constant`s are used to introduce literal values into a query, which can be useful for:
26+ /// - Comparing a field to a specific value in a `where` clause.
27+ /// - Adding new fields with fixed values using `addFields`.
28+ /// - Providing literal arguments to functions like `sum` or `average`.
29+ ///
30+ /// Example of using a `Constant` to add a new field:
31+ /// ```swift
32+ /// // Add a new field "source" with the value "manual" to each document
33+ /// firestore.pipeline()
34+ ///   .collection("entries")
35+ ///   .addFields([
36+ ///     Constant("manual").as("source")
37+ ///   ])
38+ /// ```
2139public  struct  Constant :  Expression ,  BridgeWrapper ,  @unchecked   Sendable  { 
2240  let  bridge :  ExprBridge 
2341
@@ -33,55 +51,78 @@ public struct Constant: Expression, BridgeWrapper, @unchecked Sendable {
3351    } 
3452  } 
3553
36-   // Initializer for integer
54+   /// Creates a new `Constant` expression from an integer literal.
55+   ///
56+   /// - Parameter value: The integer value.
3757  public  init ( _ value:  Int )  { 
3858    self . init ( value as  Any ) 
3959  } 
4060
41-   // Initializer for double
61+   /// Creates a new `Constant` expression from a double-precision floating-point literal.
62+   ///
63+   /// - Parameter value: The double value.
4264  public  init ( _ value:  Double )  { 
4365    self . init ( value as  Any ) 
4466  } 
4567
46-   // Initializer for strings
68+   /// Creates a new `Constant` expression from a string literal.
69+   ///
70+   /// - Parameter value: The string value.
4771  public  init ( _ value:  String )  { 
4872    self . init ( value as  Any ) 
4973  } 
5074
51-   // Initializer for boolean values
75+   /// Creates a new `Constant` expression from a boolean literal.
76+   ///
77+   /// - Parameter value: The boolean value.
5278  public  init ( _ value:  Bool )  { 
5379    self . init ( value as  Any ) 
5480  } 
5581
56-   // Initializer for Bytes
82+   /// Creates a new `Constant` expression from a `Data` (bytes) literal.
83+   ///
84+   /// - Parameter value: The `Data` value.
5785  public  init ( _ value:  Data )  { 
5886    self . init ( value as  Any ) 
5987  } 
6088
61-   // Initializer for GeoPoint values
89+   /// Creates a new `Constant` expression from a `GeoPoint` literal.
90+   ///
91+   /// - Parameter value: The `GeoPoint` value.
6292  public  init ( _ value:  GeoPoint )  { 
6393    self . init ( value as  Any ) 
6494  } 
6595
66-   // Initializer for Timestamp values
96+   /// Creates a new `Constant` expression from a `Timestamp` literal.
97+   ///
98+   /// - Parameter value: The `Timestamp` value.
6799  public  init ( _ value:  Timestamp )  { 
68100    self . init ( value as  Any ) 
69101  } 
70102
71-   // Initializer for Date values
103+   /// Creates a new `Constant` expression from a `Date` literal.
104+   ///
105+   /// The `Date` will be converted to a `Timestamp` internally.
106+   ///
107+   /// - Parameter value: The `Date` value.
72108  public  init ( _ value:  Date )  { 
73109    self . init ( value as  Any ) 
74110  } 
75111
76-   // Initializer for DocumentReference
112+   /// Creates a new `Constant` expression from a `DocumentReference` literal.
113+   ///
114+   /// - Parameter value: The `DocumentReference` value.
77115  public  init ( _ value:  DocumentReference )  { 
78116    self . init ( value as  Any ) 
79117  } 
80118
81-   // Initializer for vector values
119+   /// Creates a new `Constant` expression from a `VectorValue` literal.
120+   ///
121+   /// - Parameter value: The `VectorValue` value.
82122  public  init ( _ value:  VectorValue )  { 
83123    self . init ( value as  Any ) 
84124  } 
85125
126+   /// A `Constant` representing a `nil`  value.
86127  public  static  let  `nil` =  Constant ( nil ) 
87128} 
0 commit comments