-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom model mappings #694
Comments
+1 on this please |
We discussed this at our company all-hands week earlier this month and determined that given the wealth of available model mapping libraries, many of which are well built and actively maintained, that we won't be building model-mapping functionality into Realm itself for the foreseeable future. Here are a few libraries you can use to do this: Objective-C
Swift There are many other libraries to choose from. We hope that by investing in properly supporting these 3rd party model mapping solutions, we can focus on building features only Realm can do, while supporting these great community projects. |
Thanks for pointing those out — they seem like great options. I was hoping to be able to just throw dictionaries from my json into Objects init, but this feels like the better way to do it. Edit: the Argo link is broken if you'd like to fix that :) |
I'm having trouble implementing Decodable with Realm — @jpsim, do you have any experience with it, or an example? |
Thanks, fixed.
There are a number of examples on that project's README. If you're still having trouble implementing that, please file a new issue outlining exactly what you're doing and how it's not working. Either on this repo, or Decodable's, as you deem appropriate. |
+1 |
Has anyone found a model framework that allows for Realm Notifications and works with RealmSwift? I tried ObjectMapper, but mapping objects to JSON must be done in a Realm write block (the "inout" flag issue), which triggers the Realm Notification and falls into a infinite loop (mapping to JSON triggers a notification which triggers a mapping to JSON, etc.) |
@marksbren did you read my comment in #694 (comment)? Argo & Decodable work great with Realm. |
@jpsim thanks for the quick reply. I will try Decodable and report back |
Also — Mapper from Lyft is a great new one, I switched from Decodable and definitely like it more. All of these libraries have a few caveats to get them working with classes instead of structs though, due to Swift bugs. |
Based on the comments here about the already thriving set of third party mapping frameworks, and keeping Realm composable, we've determined that it's out of scope for Realm do perform model mapping. |
@jpsim Am I seeing things, or does Realm support this now? Using |
Realm has supported that since the launch of the Objective-C framework over two years ago. What this issue was tracking was mapping models, e.g. if the untyped dictionary input had key names that didn't match property names, or value types that didn't match property types, etc. We ended up closing this issue so we can focus on building great database features considering the great libraries that are out there that already focus on doing model mapping. |
I know it's in your pipeline, but I'd like to start scratching some code, because I really need it to my Project.
FYI: I already submitted a registration to your CLA.
The text was updated successfully, but these errors were encountered: