xref: /aosp_15_r20/external/googleapis/google/firestore/v1beta1/document.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2021 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
15syntax = "proto3";
16
17package google.firestore.v1beta1;
18
19import "google/protobuf/struct.proto";
20import "google/protobuf/timestamp.proto";
21import "google/type/latlng.proto";
22
23option csharp_namespace = "Google.Cloud.Firestore.V1Beta1";
24option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb";
25option java_multiple_files = true;
26option java_outer_classname = "DocumentProto";
27option java_package = "com.google.firestore.v1beta1";
28option objc_class_prefix = "GCFS";
29option php_namespace = "Google\\Cloud\\Firestore\\V1beta1";
30option ruby_package = "Google::Cloud::Firestore::V1beta1";
31
32// A Firestore document.
33//
34// Must not exceed 1 MiB - 4 bytes.
35message Document {
36  // The resource name of the document, for example
37  // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
38  string name = 1;
39
40  // The document's fields.
41  //
42  // The map keys represent field names.
43  //
44  // A simple field name contains only characters `a` to `z`, `A` to `Z`,
45  // `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
46  // `foo_bar_17`.
47  //
48  // Field names matching the regular expression `__.*__` are reserved. Reserved
49  // field names are forbidden except in certain documented contexts. The map
50  // keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be
51  // empty.
52  //
53  // Field paths may be used in other contexts to refer to structured fields
54  // defined here. For `map_value`, the field path is represented by the simple
55  // or quoted field names of the containing fields, delimited by `.`. For
56  // example, the structured field
57  // `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be
58  // represented by the field path `foo.x&y`.
59  //
60  // Within a field path, a quoted field name starts and ends with `` ` `` and
61  // may contain any character. Some characters, including `` ` ``, must be
62  // escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
63  // `` `bak\`tik` `` represents `` bak`tik ``.
64  map<string, Value> fields = 2;
65
66  // Output only. The time at which the document was created.
67  //
68  // This value increases monotonically when a document is deleted then
69  // recreated. It can also be compared to values from other documents and
70  // the `read_time` of a query.
71  google.protobuf.Timestamp create_time = 3;
72
73  // Output only. The time at which the document was last changed.
74  //
75  // This value is initially set to the `create_time` then increases
76  // monotonically with each change to the document. It can also be
77  // compared to values from other documents and the `read_time` of a query.
78  google.protobuf.Timestamp update_time = 4;
79}
80
81// A message that can hold any of the supported value types.
82message Value {
83  // Must have a value set.
84  oneof value_type {
85    // A null value.
86    google.protobuf.NullValue null_value = 11;
87
88    // A boolean value.
89    bool boolean_value = 1;
90
91    // An integer value.
92    int64 integer_value = 2;
93
94    // A double value.
95    double double_value = 3;
96
97    // A timestamp value.
98    //
99    // Precise only to microseconds. When stored, any additional precision is
100    // rounded down.
101    google.protobuf.Timestamp timestamp_value = 10;
102
103    // A string value.
104    //
105    // The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
106    // Only the first 1,500 bytes of the UTF-8 representation are considered by
107    // queries.
108    string string_value = 17;
109
110    // A bytes value.
111    //
112    // Must not exceed 1 MiB - 89 bytes.
113    // Only the first 1,500 bytes are considered by queries.
114    bytes bytes_value = 18;
115
116    // A reference to a document. For example:
117    // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
118    string reference_value = 5;
119
120    // A geo point value representing a point on the surface of Earth.
121    google.type.LatLng geo_point_value = 8;
122
123    // An array value.
124    //
125    // Cannot directly contain another array value, though can contain an
126    // map which contains another array.
127    ArrayValue array_value = 9;
128
129    // A map value.
130    MapValue map_value = 6;
131  }
132}
133
134// An array value.
135message ArrayValue {
136  // Values in the array.
137  repeated Value values = 1;
138}
139
140// A map value.
141message MapValue {
142  // The map's fields.
143  //
144  // The map keys represent field names. Field names matching the regular
145  // expression `__.*__` are reserved. Reserved field names are forbidden except
146  // in certain documented contexts. The map keys, represented as UTF-8, must
147  // not exceed 1,500 bytes and cannot be empty.
148  map<string, Value> fields = 1;
149}
150