RLMMongoClient.mm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2020 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import "RLMMongoClient_Private.hpp"
  19. #import "RLMMongoDatabase_Private.hpp"
  20. #import "RLMMongoCollection_Private.hpp"
  21. #import "RLMApp_Private.hpp"
  22. #import <realm/object-store/sync/mongo_client.hpp>
  23. #import <realm/object-store/sync/mongo_database.hpp>
  24. #import <realm/util/optional.hpp>
  25. @implementation RLMMongoClient
  26. - (instancetype)initWithUser:(RLMUser *)user serviceName:(NSString *)serviceName {
  27. if (self = [super init]) {
  28. _user = user;
  29. _name = serviceName;
  30. }
  31. return self;
  32. }
  33. - (RLMMongoDatabase *)databaseWithName:(NSString *)name {
  34. return [[RLMMongoDatabase alloc] initWithUser:self.user
  35. serviceName:self.name
  36. databaseName:name];
  37. }
  38. @end
  39. @implementation RLMMongoDatabase
  40. - (instancetype)initWithUser:(RLMUser *)user
  41. serviceName:(NSString *)serviceName
  42. databaseName:(NSString *)databaseName {
  43. if (self = [super init]) {
  44. _user = user;
  45. _serviceName = serviceName;
  46. _name = databaseName;
  47. }
  48. return self;
  49. }
  50. - (RLMMongoCollection *)collectionWithName:(NSString *)name {
  51. return [[RLMMongoCollection alloc] initWithUser:self.user
  52. serviceName:self.serviceName
  53. databaseName:self.name
  54. collectionName:name];
  55. }
  56. @end