@google-cloud/firestore-api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +111 -0
  2. package/build/protos/google/firestore/admin/v1/backup.proto +112 -0
  3. package/build/protos/google/firestore/admin/v1/database.proto +403 -0
  4. package/build/protos/google/firestore/admin/v1/field.proto +154 -0
  5. package/build/protos/google/firestore/admin/v1/firestore_admin.proto +1229 -0
  6. package/build/protos/google/firestore/admin/v1/index.proto +378 -0
  7. package/build/protos/google/firestore/admin/v1/location.proto +30 -0
  8. package/build/protos/google/firestore/admin/v1/operation.proto +330 -0
  9. package/build/protos/google/firestore/admin/v1/realtime_updates.proto +40 -0
  10. package/build/protos/google/firestore/admin/v1/schedule.proto +95 -0
  11. package/build/protos/google/firestore/admin/v1/snapshot.proto +53 -0
  12. package/build/protos/google/firestore/admin/v1/user_creds.proto +86 -0
  13. package/build/protos/google/firestore/v1/aggregation_result.proto +43 -0
  14. package/build/protos/google/firestore/v1/bloom_filter.proto +73 -0
  15. package/build/protos/google/firestore/v1/common.proto +111 -0
  16. package/build/protos/google/firestore/v1/document.proto +247 -0
  17. package/build/protos/google/firestore/v1/explain_stats.proto +41 -0
  18. package/build/protos/google/firestore/v1/firestore.proto +1237 -0
  19. package/build/protos/google/firestore/v1/pipeline.proto +43 -0
  20. package/build/protos/google/firestore/v1/query.proto +600 -0
  21. package/build/protos/google/firestore/v1/query_profile.proto +92 -0
  22. package/build/protos/google/firestore/v1/write.proto +286 -0
  23. package/build/protos/google/firestore/v1beta1/common.proto +82 -0
  24. package/build/protos/google/firestore/v1beta1/document.proto +149 -0
  25. package/build/protos/google/firestore/v1beta1/firestore.proto +900 -0
  26. package/build/protos/google/firestore/v1beta1/query.proto +300 -0
  27. package/build/protos/google/firestore/v1beta1/undeliverable_first_gen_event.proto +75 -0
  28. package/build/protos/google/firestore/v1beta1/write.proto +258 -0
  29. package/build/protos/protos.d.ts +35648 -0
  30. package/build/protos/protos.js +1 -0
  31. package/build/protos/protos.json +1 -0
  32. package/build/src/index.d.ts +13 -0
  33. package/build/src/index.js +30 -0
  34. package/build/src/index.js.map +1 -0
  35. package/build/src/v1/firestore_admin_client.d.ts +1925 -0
  36. package/build/src/v1/firestore_admin_client.js +2734 -0
  37. package/build/src/v1/firestore_admin_client.js.map +1 -0
  38. package/build/src/v1/firestore_admin_client_config.json +172 -0
  39. package/build/src/v1/firestore_admin_proto_list.json +13 -0
  40. package/build/src/v1/firestore_client.d.ts +1204 -0
  41. package/build/src/v1/firestore_client.js +1605 -0
  42. package/build/src/v1/firestore_client.js.map +1 -0
  43. package/build/src/v1/firestore_client_config.json +135 -0
  44. package/build/src/v1/firestore_proto_list.json +12 -0
  45. package/build/src/v1/gapic_metadata.json +351 -0
  46. package/build/src/v1/index.d.ts +2 -0
  47. package/build/src/v1/index.js +25 -0
  48. package/build/src/v1/index.js.map +1 -0
  49. package/build/src/v1beta1/firestore_client.d.ts +930 -0
  50. package/build/src/v1beta1/firestore_client.js +1310 -0
  51. package/build/src/v1beta1/firestore_client.js.map +1 -0
  52. package/build/src/v1beta1/firestore_client_config.json +99 -0
  53. package/build/src/v1beta1/firestore_proto_list.json +8 -0
  54. package/build/src/v1beta1/gapic_metadata.json +165 -0
  55. package/build/src/v1beta1/index.d.ts +1 -0
  56. package/build/src/v1beta1/index.js +23 -0
  57. package/build/src/v1beta1/index.js.map +1 -0
  58. package/package.json +65 -0
@@ -0,0 +1,43 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package google.firestore.v1;
18
+
19
+ import "google/api/field_behavior.proto";
20
+ import "google/firestore/v1/document.proto";
21
+
22
+ option csharp_namespace = "Google.Cloud.Firestore.V1";
23
+ option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb";
24
+ option java_multiple_files = true;
25
+ option java_outer_classname = "PipelineProto";
26
+ option java_package = "com.google.firestore.v1";
27
+ option objc_class_prefix = "GCFS";
28
+ option php_namespace = "Google\\Cloud\\Firestore\\V1";
29
+ option ruby_package = "Google::Cloud::Firestore::V1";
30
+
31
+ // A Firestore query represented as an ordered list of operations / stages.
32
+ //
33
+ // This is considered the top-level function which plans and executes a query.
34
+ // It is logically equivalent to `query(stages, options)`, but prevents the
35
+ // client from having to build a function wrapper.
36
+ message StructuredPipeline {
37
+ // Required. The pipeline query to execute.
38
+ Pipeline pipeline = 1 [(google.api.field_behavior) = REQUIRED];
39
+
40
+ // Optional. Optional query-level arguments.
41
+ //
42
+ map<string, Value> options = 2 [(google.api.field_behavior) = OPTIONAL];
43
+ }
@@ -0,0 +1,600 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package google.firestore.v1;
18
+
19
+ import "google/api/field_behavior.proto";
20
+ import "google/firestore/v1/document.proto";
21
+ import "google/protobuf/wrappers.proto";
22
+
23
+ option csharp_namespace = "Google.Cloud.Firestore.V1";
24
+ option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb";
25
+ option java_multiple_files = true;
26
+ option java_outer_classname = "QueryProto";
27
+ option java_package = "com.google.firestore.v1";
28
+ option objc_class_prefix = "GCFS";
29
+ option php_namespace = "Google\\Cloud\\Firestore\\V1";
30
+ option ruby_package = "Google::Cloud::Firestore::V1";
31
+
32
+ // A Firestore query.
33
+ //
34
+ // The query stages are executed in the following order:
35
+ // 1. from
36
+ // 2. where
37
+ // 3. select
38
+ // 4. order_by + start_at + end_at
39
+ // 5. offset
40
+ // 6. limit
41
+ // 7. find_nearest
42
+ message StructuredQuery {
43
+ // A selection of a collection, such as `messages as m1`.
44
+ message CollectionSelector {
45
+ // The collection ID.
46
+ // When set, selects only collections with this ID.
47
+ string collection_id = 2;
48
+
49
+ // When false, selects only collections that are immediate children of
50
+ // the `parent` specified in the containing `RunQueryRequest`.
51
+ // When true, selects all descendant collections.
52
+ bool all_descendants = 3;
53
+ }
54
+
55
+ // A filter.
56
+ message Filter {
57
+ // The type of filter.
58
+ oneof filter_type {
59
+ // A composite filter.
60
+ CompositeFilter composite_filter = 1;
61
+
62
+ // A filter on a document field.
63
+ FieldFilter field_filter = 2;
64
+
65
+ // A filter that takes exactly one argument.
66
+ UnaryFilter unary_filter = 3;
67
+ }
68
+ }
69
+
70
+ // A filter that merges multiple other filters using the given operator.
71
+ message CompositeFilter {
72
+ // A composite filter operator.
73
+ enum Operator {
74
+ // Unspecified. This value must not be used.
75
+ OPERATOR_UNSPECIFIED = 0;
76
+
77
+ // Documents are required to satisfy all of the combined filters.
78
+ AND = 1;
79
+
80
+ // Documents are required to satisfy at least one of the combined filters.
81
+ OR = 2;
82
+ }
83
+
84
+ // The operator for combining multiple filters.
85
+ Operator op = 1;
86
+
87
+ // The list of filters to combine.
88
+ //
89
+ // Requires:
90
+ //
91
+ // * At least one filter is present.
92
+ repeated Filter filters = 2;
93
+ }
94
+
95
+ // A filter on a specific field.
96
+ message FieldFilter {
97
+ // A field filter operator.
98
+ enum Operator {
99
+ // Unspecified. This value must not be used.
100
+ OPERATOR_UNSPECIFIED = 0;
101
+
102
+ // The given `field` is less than the given `value`.
103
+ //
104
+ // Requires:
105
+ //
106
+ // * That `field` come first in `order_by`.
107
+ LESS_THAN = 1;
108
+
109
+ // The given `field` is less than or equal to the given `value`.
110
+ //
111
+ // Requires:
112
+ //
113
+ // * That `field` come first in `order_by`.
114
+ LESS_THAN_OR_EQUAL = 2;
115
+
116
+ // The given `field` is greater than the given `value`.
117
+ //
118
+ // Requires:
119
+ //
120
+ // * That `field` come first in `order_by`.
121
+ GREATER_THAN = 3;
122
+
123
+ // The given `field` is greater than or equal to the given `value`.
124
+ //
125
+ // Requires:
126
+ //
127
+ // * That `field` come first in `order_by`.
128
+ GREATER_THAN_OR_EQUAL = 4;
129
+
130
+ // The given `field` is equal to the given `value`.
131
+ EQUAL = 5;
132
+
133
+ // The given `field` is not equal to the given `value`.
134
+ //
135
+ // Requires:
136
+ //
137
+ // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
138
+ // * That `field` comes first in the `order_by`.
139
+ NOT_EQUAL = 6;
140
+
141
+ // The given `field` is an array that contains the given `value`.
142
+ ARRAY_CONTAINS = 7;
143
+
144
+ // The given `field` is equal to at least one value in the given array.
145
+ //
146
+ // Requires:
147
+ //
148
+ // * That `value` is a non-empty `ArrayValue`, subject to disjunction
149
+ // limits.
150
+ // * No `NOT_IN` filters in the same query.
151
+ IN = 8;
152
+
153
+ // The given `field` is an array that contains any of the values in the
154
+ // given array.
155
+ //
156
+ // Requires:
157
+ //
158
+ // * That `value` is a non-empty `ArrayValue`, subject to disjunction
159
+ // limits.
160
+ // * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction.
161
+ // * No `NOT_IN` filters in the same query.
162
+ ARRAY_CONTAINS_ANY = 9;
163
+
164
+ // The value of the `field` is not in the given array.
165
+ //
166
+ // Requires:
167
+ //
168
+ // * That `value` is a non-empty `ArrayValue` with at most 10 values.
169
+ // * No other `OR`, `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`,
170
+ // `IS_NOT_NULL`, or `IS_NOT_NAN`.
171
+ // * That `field` comes first in the `order_by`.
172
+ NOT_IN = 10;
173
+ }
174
+
175
+ // The field to filter by.
176
+ FieldReference field = 1;
177
+
178
+ // The operator to filter by.
179
+ Operator op = 2;
180
+
181
+ // The value to compare to.
182
+ Value value = 3;
183
+ }
184
+
185
+ // A filter with a single operand.
186
+ message UnaryFilter {
187
+ // A unary operator.
188
+ enum Operator {
189
+ // Unspecified. This value must not be used.
190
+ OPERATOR_UNSPECIFIED = 0;
191
+
192
+ // The given `field` is equal to `NaN`.
193
+ IS_NAN = 2;
194
+
195
+ // The given `field` is equal to `NULL`.
196
+ IS_NULL = 3;
197
+
198
+ // The given `field` is not equal to `NaN`.
199
+ //
200
+ // Requires:
201
+ //
202
+ // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
203
+ // * That `field` comes first in the `order_by`.
204
+ IS_NOT_NAN = 4;
205
+
206
+ // The given `field` is not equal to `NULL`.
207
+ //
208
+ // Requires:
209
+ //
210
+ // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
211
+ // * That `field` comes first in the `order_by`.
212
+ IS_NOT_NULL = 5;
213
+ }
214
+
215
+ // The unary operator to apply.
216
+ Operator op = 1;
217
+
218
+ // The argument to the filter.
219
+ oneof operand_type {
220
+ // The field to which to apply the operator.
221
+ FieldReference field = 2;
222
+ }
223
+ }
224
+
225
+ // An order on a field.
226
+ message Order {
227
+ // The field to order by.
228
+ FieldReference field = 1;
229
+
230
+ // The direction to order by. Defaults to `ASCENDING`.
231
+ Direction direction = 2;
232
+ }
233
+
234
+ // A sort direction.
235
+ enum Direction {
236
+ // Unspecified.
237
+ DIRECTION_UNSPECIFIED = 0;
238
+
239
+ // Ascending.
240
+ ASCENDING = 1;
241
+
242
+ // Descending.
243
+ DESCENDING = 2;
244
+ }
245
+
246
+ // A reference to a field in a document, ex: `stats.operations`.
247
+ message FieldReference {
248
+ // A reference to a field in a document.
249
+ //
250
+ // Requires:
251
+ //
252
+ // * MUST be a dot-delimited (`.`) string of segments, where each segment
253
+ // conforms to [document field name][google.firestore.v1.Document.fields]
254
+ // limitations.
255
+ string field_path = 2;
256
+ }
257
+
258
+ // The projection of document's fields to return.
259
+ message Projection {
260
+ // The fields to return.
261
+ //
262
+ // If empty, all fields are returned. To only return the name
263
+ // of the document, use `['__name__']`.
264
+ repeated FieldReference fields = 2;
265
+ }
266
+
267
+ // Nearest Neighbors search config. The ordering provided by FindNearest
268
+ // supersedes the order_by stage. If multiple documents have the same vector
269
+ // distance, the returned document order is not guaranteed to be stable
270
+ // between queries.
271
+ message FindNearest {
272
+ // The distance measure to use when comparing vectors.
273
+ enum DistanceMeasure {
274
+ // Should not be set.
275
+ DISTANCE_MEASURE_UNSPECIFIED = 0;
276
+
277
+ // Measures the EUCLIDEAN distance between the vectors. See
278
+ // [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
279
+ // more. The resulting distance decreases the more similar two vectors
280
+ // are.
281
+ EUCLIDEAN = 1;
282
+
283
+ // COSINE distance compares vectors based on the angle between them, which
284
+ // allows you to measure similarity that isn't based on the vectors
285
+ // magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
286
+ // instead of COSINE distance, which is mathematically equivalent with
287
+ // better performance. See [Cosine
288
+ // Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
289
+ // more about COSINE similarity and COSINE distance. The resulting
290
+ // COSINE distance decreases the more similar two vectors are.
291
+ COSINE = 2;
292
+
293
+ // Similar to cosine but is affected by the magnitude of the vectors. See
294
+ // [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
295
+ // The resulting distance increases the more similar two vectors are.
296
+ DOT_PRODUCT = 3;
297
+ }
298
+
299
+ // Required. An indexed vector field to search upon. Only documents which
300
+ // contain vectors whose dimensionality match the query_vector can be
301
+ // returned.
302
+ FieldReference vector_field = 1 [(google.api.field_behavior) = REQUIRED];
303
+
304
+ // Required. The query vector that we are searching on. Must be a vector of
305
+ // no more than 2048 dimensions.
306
+ Value query_vector = 2 [(google.api.field_behavior) = REQUIRED];
307
+
308
+ // Required. The distance measure to use, required.
309
+ DistanceMeasure distance_measure = 3
310
+ [(google.api.field_behavior) = REQUIRED];
311
+
312
+ // Required. The number of nearest neighbors to return. Must be a positive
313
+ // integer of no more than 1000.
314
+ google.protobuf.Int32Value limit = 4
315
+ [(google.api.field_behavior) = REQUIRED];
316
+
317
+ // Optional. Optional name of the field to output the result of the vector
318
+ // distance calculation. Must conform to [document field
319
+ // name][google.firestore.v1.Document.fields] limitations.
320
+ string distance_result_field = 5 [(google.api.field_behavior) = OPTIONAL];
321
+
322
+ // Optional. Option to specify a threshold for which no less similar
323
+ // documents will be returned. The behavior of the specified
324
+ // `distance_measure` will affect the meaning of the distance threshold.
325
+ // Since DOT_PRODUCT distances increase when the vectors are more similar,
326
+ // the comparison is inverted.
327
+ //
328
+ // * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
329
+ // * For DOT_PRODUCT: `WHERE distance >= distance_threshold`
330
+ google.protobuf.DoubleValue distance_threshold = 6
331
+ [(google.api.field_behavior) = OPTIONAL];
332
+ }
333
+
334
+ // Optional sub-set of the fields to return.
335
+ //
336
+ // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
337
+ // documents returned from a query. When not set, assumes that the caller
338
+ // wants all fields returned.
339
+ Projection select = 1;
340
+
341
+ // The collections to query.
342
+ repeated CollectionSelector from = 2;
343
+
344
+ // The filter to apply.
345
+ Filter where = 3;
346
+
347
+ // The order to apply to the query results.
348
+ //
349
+ // Callers can provide a full ordering, a partial ordering, or no ordering at
350
+ // all. While Firestore will always respect the provided order, the behavior
351
+ // for queries without a full ordering is different per database edition:
352
+ //
353
+ // In Standard edition, Firestore guarantees a stable ordering through the
354
+ // following rules:
355
+ //
356
+ // * The `order_by` is required to reference all fields used with an
357
+ // inequality filter.
358
+ // * All fields that are required to be in the `order_by` but are not already
359
+ // present are appended in lexicographical ordering of the field name.
360
+ // * If an order on `__name__` is not specified, it is appended by default.
361
+ //
362
+ // Fields are appended with the same sort direction as the last order
363
+ // specified, or 'ASCENDING' if no order was specified. For example:
364
+ //
365
+ // * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
366
+ // * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
367
+ // * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
368
+ // * `WHERE __name__ > ... AND a > 1` becomes
369
+ // `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
370
+ //
371
+ // In Enterprise edition, Firestore does not guarantee a stable ordering.
372
+ // Instead it will pick the most efficient ordering based on the indexes
373
+ // available at the time of query execution. This will result in a different
374
+ // ordering for queries that are otherwise identical. To ensure a stable
375
+ // ordering, always include a unique field in the `order_by` clause, such as
376
+ // `__name__`.
377
+ repeated Order order_by = 4;
378
+
379
+ // A potential prefix of a position in the result set to start the query at.
380
+ //
381
+ // The ordering of the result set is based on the `ORDER BY` clause of the
382
+ // original query.
383
+ //
384
+ // ```
385
+ // SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
386
+ // ```
387
+ //
388
+ // This query's results are ordered by `(b ASC, __name__ ASC)`.
389
+ //
390
+ // Cursors can reference either the full ordering or a prefix of the location,
391
+ // though it cannot reference more fields than what are in the provided
392
+ // `ORDER BY`.
393
+ //
394
+ // Continuing off the example above, attaching the following start cursors
395
+ // will have varying impact:
396
+ //
397
+ // - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
398
+ // b > 2 AND __name__ > /k/123`.
399
+ // - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
400
+ //
401
+ // Unlike `OFFSET` which requires scanning over the first N results to skip,
402
+ // a start cursor allows the query to begin at a logical position. This
403
+ // position is not required to match an actual result, it will scan forward
404
+ // from this position to find the next document.
405
+ //
406
+ // Requires:
407
+ //
408
+ // * The number of values cannot be greater than the number of fields
409
+ // specified in the `ORDER BY` clause.
410
+ Cursor start_at = 7;
411
+
412
+ // A potential prefix of a position in the result set to end the query at.
413
+ //
414
+ // This is similar to `START_AT` but with it controlling the end position
415
+ // rather than the start position.
416
+ //
417
+ // Requires:
418
+ //
419
+ // * The number of values cannot be greater than the number of fields
420
+ // specified in the `ORDER BY` clause.
421
+ Cursor end_at = 8;
422
+
423
+ // The number of documents to skip before returning the first result.
424
+ //
425
+ // This applies after the constraints specified by the `WHERE`, `START AT`, &
426
+ // `END AT` but before the `LIMIT` clause.
427
+ //
428
+ // Requires:
429
+ //
430
+ // * The value must be greater than or equal to zero if specified.
431
+ int32 offset = 6;
432
+
433
+ // The maximum number of results to return.
434
+ //
435
+ // Applies after all other constraints.
436
+ //
437
+ // Requires:
438
+ //
439
+ // * The value must be greater than or equal to zero if specified.
440
+ google.protobuf.Int32Value limit = 5;
441
+
442
+ // Optional. A potential nearest neighbors search.
443
+ //
444
+ // Applies after all other filters and ordering.
445
+ //
446
+ // Finds the closest vector embeddings to the given query vector.
447
+ FindNearest find_nearest = 9 [(google.api.field_behavior) = OPTIONAL];
448
+ }
449
+
450
+ // Firestore query for running an aggregation over a
451
+ // [StructuredQuery][google.firestore.v1.StructuredQuery].
452
+ message StructuredAggregationQuery {
453
+ // Defines an aggregation that produces a single result.
454
+ message Aggregation {
455
+ // Count of documents that match the query.
456
+ //
457
+ // The `COUNT(*)` aggregation function operates on the entire document
458
+ // so it does not require a field reference.
459
+ message Count {
460
+ // Optional. Optional constraint on the maximum number of documents to
461
+ // count.
462
+ //
463
+ // This provides a way to set an upper bound on the number of documents
464
+ // to scan, limiting latency, and cost.
465
+ //
466
+ // Unspecified is interpreted as no bound.
467
+ //
468
+ // High-Level Example:
469
+ //
470
+ // ```
471
+ // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
472
+ // ```
473
+ //
474
+ // Requires:
475
+ //
476
+ // * Must be greater than zero when present.
477
+ google.protobuf.Int64Value up_to = 1
478
+ [(google.api.field_behavior) = OPTIONAL];
479
+ }
480
+
481
+ // Sum of the values of the requested field.
482
+ //
483
+ // * Only numeric values will be aggregated. All non-numeric values
484
+ // including `NULL` are skipped.
485
+ //
486
+ // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
487
+ // follows IEEE-754 standards.
488
+ //
489
+ // * If the aggregated value set is empty, returns 0.
490
+ //
491
+ // * Returns a 64-bit integer if all aggregated numbers are integers and the
492
+ // sum result does not overflow. Otherwise, the result is returned as a
493
+ // double. Note that even if all the aggregated values are integers, the
494
+ // result is returned as a double if it cannot fit within a 64-bit signed
495
+ // integer. When this occurs, the returned value will lose precision.
496
+ //
497
+ // * When underflow occurs, floating-point aggregation is non-deterministic.
498
+ // This means that running the same query repeatedly without any changes to
499
+ // the underlying values could produce slightly different results each
500
+ // time. In those cases, values should be stored as integers over
501
+ // floating-point numbers.
502
+ message Sum {
503
+ // The field to aggregate on.
504
+ StructuredQuery.FieldReference field = 1;
505
+ }
506
+
507
+ // Average of the values of the requested field.
508
+ //
509
+ // * Only numeric values will be aggregated. All non-numeric values
510
+ // including `NULL` are skipped.
511
+ //
512
+ // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
513
+ // follows IEEE-754 standards.
514
+ //
515
+ // * If the aggregated value set is empty, returns `NULL`.
516
+ //
517
+ // * Always returns the result as a double.
518
+ message Avg {
519
+ // The field to aggregate on.
520
+ StructuredQuery.FieldReference field = 1;
521
+ }
522
+
523
+ // The type of aggregation to perform, required.
524
+ oneof operator {
525
+ // Count aggregator.
526
+ Count count = 1;
527
+
528
+ // Sum aggregator.
529
+ Sum sum = 2;
530
+
531
+ // Average aggregator.
532
+ Avg avg = 3;
533
+ }
534
+
535
+ // Optional. Optional name of the field to store the result of the
536
+ // aggregation into.
537
+ //
538
+ // If not provided, Firestore will pick a default name following the format
539
+ // `field_<incremental_id++>`. For example:
540
+ //
541
+ // ```
542
+ // AGGREGATE
543
+ // COUNT_UP_TO(1) AS count_up_to_1,
544
+ // COUNT_UP_TO(2),
545
+ // COUNT_UP_TO(3) AS count_up_to_3,
546
+ // COUNT(*)
547
+ // OVER (
548
+ // ...
549
+ // );
550
+ // ```
551
+ //
552
+ // becomes:
553
+ //
554
+ // ```
555
+ // AGGREGATE
556
+ // COUNT_UP_TO(1) AS count_up_to_1,
557
+ // COUNT_UP_TO(2) AS field_1,
558
+ // COUNT_UP_TO(3) AS count_up_to_3,
559
+ // COUNT(*) AS field_2
560
+ // OVER (
561
+ // ...
562
+ // );
563
+ // ```
564
+ //
565
+ // Requires:
566
+ //
567
+ // * Must be unique across all aggregation aliases.
568
+ // * Conform to [document field name][google.firestore.v1.Document.fields]
569
+ // limitations.
570
+ string alias = 7 [(google.api.field_behavior) = OPTIONAL];
571
+ }
572
+
573
+ // The base query to aggregate over.
574
+ oneof query_type {
575
+ // Nested structured query.
576
+ StructuredQuery structured_query = 1;
577
+ }
578
+
579
+ // Optional. Series of aggregations to apply over the results of the
580
+ // `structured_query`.
581
+ //
582
+ // Requires:
583
+ //
584
+ // * A minimum of one and maximum of five aggregations per query.
585
+ repeated Aggregation aggregations = 3
586
+ [(google.api.field_behavior) = OPTIONAL];
587
+ }
588
+
589
+ // A position in a query result set.
590
+ message Cursor {
591
+ // The values that represent a position, in the order they appear in
592
+ // the order by clause of a query.
593
+ //
594
+ // Can contain fewer values than specified in the order by clause.
595
+ repeated Value values = 1;
596
+
597
+ // If the position is just before or just after the given values, relative
598
+ // to the sort order defined by the query.
599
+ bool before = 2;
600
+ }