bundle.proto 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright 2020 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. // This file defines the format of Firestore bundle file/stream. It is not a part of the
  16. // Firestore API, only a specification used by Server and Client SDK to write and read
  17. // bundles.
  18. syntax = "proto3";
  19. package google.firestore.bundle;
  20. import "google/firestore/v1/document.proto";
  21. import "google/firestore/v1/query.proto";
  22. import "google/protobuf/timestamp.proto";
  23. option csharp_namespace = "Firestore.Bundle";
  24. option go_package = "google.golang.org/genproto/firestore/bundle;firestore";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "BundleProto";
  27. option java_package = "com.google.firestore.bundle";
  28. option objc_class_prefix = "FSTPB";
  29. option php_namespace = "Firestore\\Bundle";
  30. // Encodes a query saved in the bundle.
  31. message BundledQuery {
  32. // The parent resource name.
  33. string parent = 1;
  34. // The query to run.
  35. oneof query_type {
  36. // A structured query.
  37. google.firestore.v1.StructuredQuery structured_query = 2;
  38. }
  39. // If the query is a limit query, should the limit be applied to the beginning or
  40. // the end of results.
  41. enum LimitType {
  42. FIRST = 0;
  43. LAST = 1;
  44. }
  45. LimitType limit_type = 3;
  46. }
  47. // A Query associated with a name, created as part of the bundle file, and can be read
  48. // by client SDKs once the bundle containing them is loaded.
  49. message NamedQuery {
  50. // Name of the query, such that client can use the name to load this query
  51. // from bundle, and resume from when the query results are materialized
  52. // into this bundle.
  53. string name = 1;
  54. // The query saved in the bundle.
  55. BundledQuery bundled_query = 2;
  56. // The read time of the query, when it is used to build the bundle. This is useful to
  57. // resume the query from the bundle, once it is loaded by client SDKs.
  58. google.protobuf.Timestamp read_time = 3;
  59. }
  60. // Metadata describing a Firestore document saved in the bundle.
  61. message BundledDocumentMetadata {
  62. // The document key of a bundled document.
  63. string name = 1;
  64. // The snapshot version of the document data bundled.
  65. google.protobuf.Timestamp read_time = 2;
  66. // Whether the document exists.
  67. bool exists = 3;
  68. // The names of the queries in this bundle that this document matches to.
  69. repeated string queries = 4;
  70. }
  71. // Metadata describing the bundle file/stream.
  72. message BundleMetadata {
  73. // The ID of the bundle.
  74. string id = 1;
  75. // Time at which the documents snapshot is taken for this bundle.
  76. google.protobuf.Timestamp create_time = 2;
  77. // The schema version of the bundle.
  78. uint32 version = 3;
  79. // The number of documents in the bundle.
  80. uint32 total_documents = 4;
  81. // The size of the bundle in bytes, excluding this `BundleMetadata`.
  82. uint64 total_bytes = 5;
  83. }
  84. // A Firestore bundle is a length-prefixed stream of JSON representations of
  85. // `BundleElement`.
  86. // Only one `BundleMetadata` is expected, and it should be the first element.
  87. // The named queries follow after `metadata`. Every `document_metadata` is
  88. // immediately followed by a `document`.
  89. message BundleElement {
  90. oneof element_type {
  91. BundleMetadata metadata = 1;
  92. NamedQuery named_query = 2;
  93. BundledDocumentMetadata document_metadata = 3;
  94. google.firestore.v1.Document document = 4;
  95. }
  96. }