realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.34k stars 2.15k forks source link

Add back support for mapping Swift structs to collections in Atlas, a functionality removed from Stitch #7272

Open puiz666 opened 3 years ago

puiz666 commented 3 years ago

Goals

I have a Swift struct, and I want to add it to my collection in Atlas. Previously, I was able to map a struct to a collection:

let itemsCollection = mongoServiceClient.db(“myDatabase”).collection(“myCollection”, withCollectionType: MyStruct.self)
itemsCollection.insertOne(myStruct) 

After the Realm integration, this functionality seems to be absent. Instead, the SDK now expects me to convert my Swift struct into a Realm-supported, Objective-C-compatible Object subclass, which is a very significant regression:

I understand that Realm provides a local persistency functionality for the objects it manages, and syncing that into MongoDB adds a lot of value for certain use cases. I also understand that the Realm SDK might have been written in Objective-C, and only recently migrated to Swift. Finally, I also understand that it may be a tempting idea to maintain feature-compatibility with Objective-C.

However, I also believe the following should be important considerations:

Expected Results

Please consider the following:

dianaafanador3 commented 3 years ago

@puiz666 Thanks for taking the time to comment, we take into account all our community inputs. We'll let you know any further actions we take from your comments.