Skip to content

Commit 55c698b

Browse files
authored
Implement indexing for bson types. (#798)
* Add RegexValue class. * Add to/from proto logic. * Add comparison logic and unit tests. * Add serializer unit test. * Add Codable support, Improve Swift API, Add integration test. * Add more unit tests and integration tests. Also fixed a bug found by unit tests. * Add 6 other types' public API. * rename `.m` to `.mm` to stay consistent. * More unit tests. * WIP: Add the FieldValue methods for building new types. * Add the Swift API and the Obj-C Unit tests. * Add UserDataReader support for new types. * Add missing `extern`. * Add UserDataWriter support for types. Int32 is still missing. * UserDataWriter support for int32. * Update TypeOrder usages with new types. * Add comparison logic for more types. * Add Int32Value comparison logic. * Add SerializerTests for more types. * Use snake case. * Add more unit tests. * Fix bug and add integration test. * Add more integration tests. * Add more integration tests. * Add more integration and unit tests. * Expose public `isEqual` for new types and add tests for it. * Add cross-type order test. * Add Codable support along with integration tests for them. * Remove named parameter for Int32Value and BsonObjectId. * clang-format. * Use `uint8_t` for BsonBinaryData's subtype. * Add `description` for new types. * Reuse type check logic for new types. * Use uint8_t for BsonBinaryData. * Adds tests for FIRFieldValue static c'tors of new types. * Add a few missing tests. * Update tests to check listeners, src=cache, src=server. * Implement indexing for bson types. * Add test for offline write and read from cache. * WIP: Adding more unit tests and integration tests. * Add IndexAllTypesTogether test. * Properly handle empty segments in ref. * Add ComputesLowerBound test. * Add ComputesUpperBound test. * Add IndexValueWriterTest. * Add bson types to index_value_writer_test.cc. * Add CSI tests for bson types. * Check ordered results for queries served from the index. * Add TODO for failing tests. * Address comments. * Improve doc ordering in the new leveldb_local_store_test tests.
1 parent aa9ab04 commit 55c698b

22 files changed

+2563
-118
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@
276276
26C4E52128C8E7B5B96BECC4 /* defer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8ABAC2E0402213D837F73DC3 /* defer_test.cc */; };
277277
26C577D159CFFD73E24D543C /* memory_mutation_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 74FBEFA4FE4B12C435011763 /* memory_mutation_queue_test.cc */; };
278278
26CB3D7C871BC56456C6021E /* timestamp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABF6506B201131F8005F2C74 /* timestamp_test.cc */; };
279+
26E36A01DA79CC72F88E3A21 /* index_value_writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */; };
279280
276A563D546698B6AAC20164 /* annotations.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 618BBE9520B89AAC00B5BCE7 /* annotations.pb.cc */; };
280281
27AF4C4BAFE079892D4F5341 /* Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4B3E4A77493524333133C5DC /* Validation_BloomFilterTest_MD5_50000_1_bloom_filter_proto.json */; };
281282
27E46C94AAB087C80A97FF7F /* FIRServerTimestampTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E06E202154D600B64F25 /* FIRServerTimestampTests.mm */; };
@@ -299,6 +300,7 @@
299300
2AD8EE91928AE68DF268BEDA /* limbo_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA129E1F315EE100DD57A1 /* limbo_spec_test.json */; };
300301
2AD98CD29CC6F820A74CDD5E /* Validation_BloomFilterTest_MD5_1_0001_bloom_filter_proto.json in Resources */ = {isa = PBXBuildFile; fileRef = 4B59C0A7B2A4548496ED4E7D /* Validation_BloomFilterTest_MD5_1_0001_bloom_filter_proto.json */; };
301302
2AE3914BBC4EDF91BD852939 /* memory_query_engine_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8EF6A33BC2D84233C355F1D0 /* memory_query_engine_test.cc */; };
303+
2B3C73B6702180419FC5460A /* index_value_writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */; };
302304
2B4021C3E663DDDDD512E961 /* objc_type_traits_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2A0CF41BA5AED6049B0BEB2C /* objc_type_traits_apple_test.mm */; };
303305
2B4234B962625F9EE68B31AC /* index_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AE4A9E38D65688EE000EE2A1 /* index_manager_test.cc */; };
304306
2B4D0509577E5CE0B0B8CEDF /* message_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE37875365497FFA8687B745 /* message_test.cc */; };
@@ -501,6 +503,7 @@
501503
4DAF501EE4B4DB79ED4239B0 /* secure_random_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54740A531FC913E500713A1A /* secure_random_test.cc */; };
502504
4DAFC3A3FD5E96910A517320 /* fake_target_metadata_provider.cc in Sources */ = {isa = PBXBuildFile; fileRef = 71140E5D09C6E76F7C71B2FC /* fake_target_metadata_provider.cc */; };
503505
4DC660A62BC2B6369DA5C563 /* status_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54A0352C20A3B3D7003E0143 /* status_test.cc */; };
506+
4DE1DCA66D728E812A72F624 /* index_value_writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */; };
504507
4DF18D15AC926FB7A4888313 /* lru_garbage_collector_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */; };
505508
4E0777435A9A26B8B2C08A1E /* remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7EB299CF85034F09CFD6F3FD /* remote_document_cache_test.cc */; };
506509
4E2E0314F9FDD7BCED60254A /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
@@ -1056,6 +1059,7 @@
10561059
977E0DA564D6EAF975A4A1A0 /* settings_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = DD12BC1DB2480886D2FB0005 /* settings_test.cc */; };
10571060
9783FAEA4CF758E8C4C2D76E /* hashing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54511E8D209805F8005BD28F /* hashing_test.cc */; };
10581061
978D9EFDC56CC2E1FA468712 /* leveldb_snappy_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D9D94300B9C02F7069523C00 /* leveldb_snappy_test.cc */; };
1062+
984135015B443110FF60F86F /* index_value_writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */; };
10591063
9860F493EBF43AF5AC0A88BD /* empty_credentials_provider_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8FA60B08D59FEA0D6751E87F /* empty_credentials_provider_test.cc */; };
10601064
98708140787A9465D883EEC9 /* leveldb_mutation_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5C7942B6244F4C416B11B86C /* leveldb_mutation_queue_test.cc */; };
10611065
98FE82875A899A40A98AAC22 /* leveldb_opener_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 75860CD13AF47EB1EA39EC2F /* leveldb_opener_test.cc */; };
@@ -1105,6 +1109,7 @@
11051109
A25FF76DEF542E01A2DF3B0E /* time_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5497CB76229DECDE000FB92F /* time_testing.cc */; };
11061110
A27096F764227BC73526FED3 /* leveldb_remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0840319686A223CC4AD3FAB1 /* leveldb_remote_document_cache_test.cc */; };
11071111
A27908A198E1D2230C1801AC /* bundle_serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5C2A94EE24E60543F62CC35 /* bundle_serializer_test.cc */; };
1112+
A2905C9606C844D7C44B21D7 /* index_value_writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */; };
11081113
A2E9978E02F7BCB016555F09 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json in Resources */ = {isa = PBXBuildFile; fileRef = 3369AC938F82A70685C5ED58 /* Validation_BloomFilterTest_MD5_1_1_membership_test_result.json */; };
11091114
A3262936317851958C8EABAF /* byte_stream_cpp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 01D10113ECC5B446DB35E96D /* byte_stream_cpp_test.cc */; };
11101115
A4757C171D2407F61332EA38 /* byte_stream_cpp_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 01D10113ECC5B446DB35E96D /* byte_stream_cpp_test.cc */; };
@@ -1377,6 +1382,7 @@
13771382
CE2962775B42BDEEE8108567 /* leveldb_lru_garbage_collector_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B629525F7A1AAC1AB765C74F /* leveldb_lru_garbage_collector_test.cc */; };
13781383
CE411D4B70353823DE63C0D5 /* bundle_loader_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = A853C81A6A5A51C9D0389EDA /* bundle_loader_test.cc */; };
13791384
CEA91CE103B42533C54DBAD6 /* memory_remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1CA9800A53669EFBFFB824E3 /* memory_remote_document_cache_test.cc */; };
1385+
CEE39EC40FC07EBB02C2E341 /* index_value_writer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */; };
13801386
CF18D52A88F4F6F62C5495EF /* thread_safe_memoizer_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6E42FA109D363EA7F3387AAE /* thread_safe_memoizer_testing.cc */; };
13811387
CF1FB026CCB901F92B4B2C73 /* watch_change_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2D7472BC70C024D736FF74D9 /* watch_change_test.cc */; };
13821388
CF5DE1ED21DD0A9783383A35 /* CodableIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124C932B22C1642C00CA8C2D /* CodableIntegrationTests.swift */; };
@@ -1749,6 +1755,7 @@
17491755
214877F52A705012D6720CA0 /* object_value_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = object_value_test.cc; sourceTree = "<group>"; };
17501756
2220F583583EFC28DE792ABE /* Pods_Firestore_IntegrationTests_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_IntegrationTests_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
17511757
2286F308EFB0534B1BDE05B9 /* memory_target_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = memory_target_cache_test.cc; sourceTree = "<group>"; };
1758+
22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; name = index_value_writer_test.cc; path = index/index_value_writer_test.cc; sourceTree = "<group>"; };
17521759
26DDBA115DEB88631B93F203 /* thread_safe_memoizer_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = thread_safe_memoizer_testing.h; sourceTree = "<group>"; };
17531760
277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = lru_garbage_collector_test.cc; sourceTree = "<group>"; };
17541761
28B45B2104E2DAFBBF86DBB7 /* logic_utils_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = logic_utils_test.cc; sourceTree = "<group>"; };
@@ -2461,6 +2468,7 @@
24612468
AB380CF7201937B800D97691 /* core */,
24622469
11BB7A1B7F6F482EFDBC5303 /* credentials */,
24632470
54EB764B202277970088B8F3 /* immutable */,
2471+
F952916DDF5B3977111173CC /* index */,
24642472
54995F70205B6E1A004EFFA0 /* local */,
24652473
AB356EF5200E9D1A0089B766 /* model */,
24662474
5C332D7293E6114E491D3662 /* nanopb */,
@@ -3107,6 +3115,14 @@
31073115
name = bundle;
31083116
sourceTree = "<group>";
31093117
};
3118+
F952916DDF5B3977111173CC /* index */ = {
3119+
isa = PBXGroup;
3120+
children = (
3121+
22B1FBDD47024F03B8CAA054 /* index_value_writer_test.cc */,
3122+
);
3123+
name = index;
3124+
sourceTree = "<group>";
3125+
};
31103126
/* End PBXGroup section */
31113127

31123128
/* Begin PBXNativeTarget section */
@@ -4273,6 +4289,7 @@
42734289
48BC5801432127A90CFF55E3 /* index.pb.cc in Sources */,
42744290
167659CDCA47B450F2441454 /* index_backfiller_test.cc in Sources */,
42754291
FAD97B82766AEC29B7B5A1B7 /* index_manager_test.cc in Sources */,
4292+
26E36A01DA79CC72F88E3A21 /* index_value_writer_test.cc in Sources */,
42764293
E084921EFB7CF8CB1E950D6C /* iterator_adaptors_test.cc in Sources */,
42774294
49C04B97AB282FFA82FD98CD /* latlng.pb.cc in Sources */,
42784295
292BCC76AF1B916752764A8F /* leveldb_bundle_cache_test.cc in Sources */,
@@ -4497,6 +4514,7 @@
44974514
190F9885BAA81587F08CD26C /* index.pb.cc in Sources */,
44984515
B845B9EDED330D0FDAD891BC /* index_backfiller_test.cc in Sources */,
44994516
F58A23FEF328EB74F681FE83 /* index_manager_test.cc in Sources */,
4517+
CEE39EC40FC07EBB02C2E341 /* index_value_writer_test.cc in Sources */,
45004518
0E4C94369FFF7EC0C9229752 /* iterator_adaptors_test.cc in Sources */,
45014519
0FBDD5991E8F6CD5F8542474 /* latlng.pb.cc in Sources */,
45024520
513D34C9964E8C60C5C2EE1C /* leveldb_bundle_cache_test.cc in Sources */,
@@ -4747,6 +4765,7 @@
47474765
096BA3A3703AC1491F281618 /* index.pb.cc in Sources */,
47484766
9236478E01DF2EC7DF58B1FC /* index_backfiller_test.cc in Sources */,
47494767
4BFEEB7FDD7CD5A693B5B5C1 /* index_manager_test.cc in Sources */,
4768+
4DE1DCA66D728E812A72F624 /* index_value_writer_test.cc in Sources */,
47504769
FA334ADC73CFDB703A7C17CD /* iterator_adaptors_test.cc in Sources */,
47514770
CBC891BEEC525F4D8F40A319 /* latlng.pb.cc in Sources */,
47524771
2E76BC76BBCE5FCDDCF5EEBE /* leveldb_bundle_cache_test.cc in Sources */,
@@ -4997,6 +5016,7 @@
49975016
6E8CD8F545C8EDA84918977C /* index.pb.cc in Sources */,
49985017
E25DCFEF318E003B8B7B9DC8 /* index_backfiller_test.cc in Sources */,
49995018
650B31A5EC6F8D2AEA79C350 /* index_manager_test.cc in Sources */,
5019+
A2905C9606C844D7C44B21D7 /* index_value_writer_test.cc in Sources */,
50005020
86494278BE08F10A8AAF9603 /* iterator_adaptors_test.cc in Sources */,
50015021
4173B61CB74EB4CD1D89EE68 /* latlng.pb.cc in Sources */,
50025022
1E8F5F37052AB0C087D69DF9 /* leveldb_bundle_cache_test.cc in Sources */,
@@ -5231,6 +5251,7 @@
52315251
77D38E78F7CCB8504450A8FB /* index.pb.cc in Sources */,
52325252
76FEBDD2793B729BAD2E84C7 /* index_backfiller_test.cc in Sources */,
52335253
E6357221227031DD77EE5265 /* index_manager_test.cc in Sources */,
5254+
2B3C73B6702180419FC5460A /* index_value_writer_test.cc in Sources */,
52345255
54A0353520A3D8CB003E0143 /* iterator_adaptors_test.cc in Sources */,
52355256
618BBEAE20B89AAC00B5BCE7 /* latlng.pb.cc in Sources */,
52365257
0EDFC8A6593477E1D17CDD8F /* leveldb_bundle_cache_test.cc in Sources */,
@@ -5500,6 +5521,7 @@
55005521
78E8DDDBE131F3DA9AF9F8B8 /* index.pb.cc in Sources */,
55015522
CCE596E8654A4D2EEA75C219 /* index_backfiller_test.cc in Sources */,
55025523
2B4234B962625F9EE68B31AC /* index_manager_test.cc in Sources */,
5524+
984135015B443110FF60F86F /* index_value_writer_test.cc in Sources */,
55035525
8A79DDB4379A063C30A76329 /* iterator_adaptors_test.cc in Sources */,
55045526
23C04A637090E438461E4E70 /* latlng.pb.cc in Sources */,
55055527
77C459976DCF7503AEE18F7F /* leveldb_bundle_cache_test.cc in Sources */,

Firestore/Example/Tests/API/FIRFieldValueTests.mm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ - (void)testEquals {
4848
XCTAssertNotEqual([deleted hash], [serverTimestamp hash]);
4949
}
5050

51+
- (void)testCanCreateRegexValue {
52+
FIRRegexValue *regex = [FIRFieldValue regexWithPattern:@"^foo" options:@"x"];
53+
XCTAssertEqual(regex.pattern, @"^foo");
54+
XCTAssertEqual(regex.options, @"x");
55+
}
56+
57+
- (void)testCanCreateInt32Value {
58+
FIRInt32Value *int1 = [FIRFieldValue int32WithValue:1234];
59+
XCTAssertEqual(int1.value, 1234);
60+
61+
FIRInt32Value *int2 = [FIRFieldValue int32WithValue:-1234];
62+
XCTAssertEqual(int2.value, -1234);
63+
}
64+
65+
- (void)testCanCreateBsonObjectId {
66+
FIRBsonObjectId *objectId = [FIRFieldValue bsonObjectIdWithValue:@"foo"];
67+
XCTAssertEqual(objectId.value, @"foo");
68+
}
69+
70+
- (void)testCanCreateBsonTimestamp {
71+
FIRBsonTimestamp *timestamp = [FIRFieldValue bsonTimestampWithSeconds:123 increment:456];
72+
XCTAssertEqual(timestamp.seconds, 123U);
73+
XCTAssertEqual(timestamp.increment, 456U);
74+
}
75+
76+
- (void)testCanCreateBsonBinaryData {
77+
FIRBsonBinaryData *binData = [FIRFieldValue bsonBinaryDataWithSubtype:128
78+
data:FSTTestData(1, 2, 3, -1)];
79+
XCTAssertEqual(binData.subtype, 128);
80+
XCTAssertTrue([binData.data isEqualToData:FSTTestData(1, 2, 3, -1)]);
81+
}
82+
5183
@end
5284

5385
NS_ASSUME_NONNULL_END

Firestore/Source/API/FIRFieldValue.mm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,36 @@ + (nonnull FIRVectorValue *)vectorWithArray:(nonnull NSArray<NSNumber *> *)array
188188
return [[FIRVectorValue alloc] initWithArray:array];
189189
}
190190

191+
+ (nonnull FIRMinKey *)minKey {
192+
return [FIRMinKey instance];
193+
}
194+
195+
+ (nonnull FIRMaxKey *)maxKey {
196+
return [FIRMaxKey instance];
197+
}
198+
199+
+ (nonnull FIRRegexValue *)regexWithPattern:(nonnull NSString *)pattern
200+
options:(nonnull NSString *)options {
201+
return [[FIRRegexValue alloc] initWithPattern:pattern options:options];
202+
}
203+
204+
+ (nonnull FIRInt32Value *)int32WithValue:(int)value {
205+
return [[FIRInt32Value alloc] initWithValue:value];
206+
}
207+
208+
+ (nonnull FIRBsonObjectId *)bsonObjectIdWithValue:(NSString *)value {
209+
return [[FIRBsonObjectId alloc] initWithValue:value];
210+
}
211+
212+
+ (nonnull FIRBsonTimestamp *)bsonTimestampWithSeconds:(uint32_t)seconds
213+
increment:(uint32_t)increment {
214+
return [[FIRBsonTimestamp alloc] initWithSeconds:seconds increment:increment];
215+
}
216+
217+
+ (nonnull FIRBsonBinaryData *)bsonBinaryDataWithSubtype:(uint8_t)subtype data:(NSData *)data {
218+
return [[FIRBsonBinaryData alloc] initWithSubtype:subtype data:data];
219+
}
220+
191221
@end
192222

193223
NS_ASSUME_NONNULL_END

Firestore/Source/API/FSTUserDataWriter.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ - (id)convertedValue:(const google_firestore_v1_Value &)value {
135135
return [self convertedBsonBinaryData:value.map_value];
136136
case TypeOrder::kVector:
137137
return [self convertedVector:value.map_value];
138-
case TypeOrder::kMaxValue:
139-
// It is not possible for users to construct a kMaxValue manually.
138+
case TypeOrder::kInternalMaxValue:
139+
// It is not possible for users to construct a kInternalMaxValue manually.
140140
break;
141141
}
142142

Firestore/Source/Public/FirebaseFirestore/FIRFieldValue.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,67 @@ NS_SWIFT_NAME(FieldValue)
107107
*/
108108
+ (FIRVectorValue *)vectorWithArray:(NSArray<NSNumber *> *)array NS_REFINED_FOR_SWIFT;
109109

110+
/**
111+
* Returns a `MinKey` value instance.
112+
*
113+
* @return A `MinKey` value instance.
114+
*/
115+
+ (nonnull FIRMinKey *)minKey NS_REFINED_FOR_SWIFT;
116+
117+
/**
118+
* Returns a `MaxKey` value instance.
119+
*
120+
* @return A `MaxKey` value instance.
121+
*/
122+
+ (nonnull FIRMaxKey *)maxKey NS_REFINED_FOR_SWIFT;
123+
124+
/**
125+
* Creates a new `RegexValue` constructed with the given pattern and options.
126+
*
127+
* @param pattern The pattern to use for the regular expression.
128+
* @param options The options to use for the regular expression.
129+
* @return A new `RegexValue` constructed with the given pattern and options.
130+
*/
131+
+ (nonnull FIRRegexValue *)regexWithPattern:(nonnull NSString *)pattern
132+
options:(nonnull NSString *)options NS_REFINED_FOR_SWIFT;
133+
134+
/**
135+
* Creates a new `Int32Value` with the given signed 32-bit integer value.
136+
*
137+
* @param value The 32-bit number to be used for constructing the Int32Value.
138+
* @return A new `Int32Value` instance.
139+
*/
140+
+ (nonnull FIRInt32Value *)int32WithValue:(int)value NS_REFINED_FOR_SWIFT;
141+
142+
/**
143+
* Creates a new `BsonObjectId` with the given value.
144+
*
145+
* @param value The 24-character hex string representation of the ObjectId.
146+
* @return A new `BsonObjectId` instance constructed with the given value.
147+
*/
148+
+ (nonnull FIRBsonObjectId *)bsonObjectIdWithValue:(nonnull NSString *)value NS_REFINED_FOR_SWIFT;
149+
150+
/**
151+
* Creates a new `BsonTimestamp` with the given values.
152+
*
153+
* @param seconds The underlying unsigned 32-bit integer for seconds.
154+
* @param increment The underlying unsigned 32-bit integer for increment.
155+
* @return A new `BsonTimestamp` instance constructed with the given values.
156+
*/
157+
+ (nonnull FIRBsonTimestamp *)bsonTimestampWithSeconds:(uint32_t)seconds
158+
increment:(uint32_t)increment NS_REFINED_FOR_SWIFT;
159+
160+
/**
161+
* Creates a new `BsonBinaryData` object with the given subtype and data.
162+
*
163+
* @param subtype An 8-bit unsigned integer denoting the subtype of the data.
164+
* @param data The binary data.
165+
* @return A new `BsonBinaryData` instance constructed with the given values.
166+
*/
167+
+ (nonnull FIRBsonBinaryData *)bsonBinaryDataWithSubtype:(uint8_t)subtype
168+
data:(nonnull NSData *)data
169+
NS_REFINED_FOR_SWIFT;
170+
110171
@end
111172

112173
NS_ASSUME_NONNULL_END

Firestore/Swift/Source/SwiftAPI/FieldValue+Swift.swift

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,54 @@ public extension FieldValue {
4040
}
4141
return FieldValue.__vector(with: nsNumbers)
4242
}
43+
44+
/// Returns a `MinKey` instance.
45+
/// - Returns: A `MinKey` instance.
46+
static func minKey() -> MinKey {
47+
return FieldValue.__minKey()
48+
}
49+
50+
/// Returns a `MaxKey` instance.
51+
/// - Returns: A `MaxKey` instance.
52+
static func maxKey() -> MaxKey {
53+
return FieldValue.__maxKey()
54+
}
55+
56+
/// Creates a new `RegexValue` constructed with the given pattern and options.
57+
/// - Parameter pattern: The pattern of the regular expression.
58+
/// - Parameter options: The options of the regular expression.
59+
/// - Returns: A new `RegexValue` constructed with the given pattern and options.
60+
static func regex(pattern: String, options: String) -> RegexValue {
61+
return FieldValue.__regex(withPattern: pattern, options: options)
62+
}
63+
64+
/// Creates a new `Int32Value` with the given signed 32-bit integer value.
65+
/// - Parameter value: The 32-bit number to be used for constructing the Int32Value.
66+
/// - Returns: A new `Int32Value` instance.
67+
static func int32(_ value: Int32) -> Int32Value {
68+
return FieldValue.__int32(withValue: value)
69+
}
70+
71+
/// Creates a new `BsonObjectId` with the given value.
72+
/// - Parameter value: The 24-character hex string representation of the ObjectId.
73+
/// - Returns: A new `BsonObjectId` instance constructed with the given value.
74+
static func bsonObjectId(_ value: String) -> BsonObjectId {
75+
return FieldValue.__bsonObjectId(withValue: value)
76+
}
77+
78+
/// Creates a new `BsonTimestamp` with the given values.
79+
/// @param seconds The underlying unsigned 32-bit integer for seconds.
80+
/// @param increment The underlying unsigned 32-bit integer for increment.
81+
/// @return A new `BsonTimestamp` instance constructed with the given values.
82+
static func bsonTimestamp(seconds: UInt32, increment: UInt32) -> BsonTimestamp {
83+
return FieldValue.__bsonTimestamp(withSeconds: seconds, increment: increment)
84+
}
85+
86+
/// Creates a new `BsonBinaryData` object with the given subtype and data.
87+
/// @param subtype The subtype of the data.
88+
/// @param data The binary data.
89+
/// @return A new `BsonBinaryData` instance constructed with the given values.
90+
static func bsonBinaryData(subtype: UInt8, data: Data) -> BsonBinaryData {
91+
return FieldValue.__bsonBinaryData(withSubtype: subtype, data: data)
92+
}
4393
}

0 commit comments

Comments
 (0)