Skip to content
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

Closed
c0rrzin opened this issue Jul 28, 2014 · 13 comments
Closed

Support custom model mappings #694

c0rrzin opened this issue Jul 28, 2014 · 13 comments

Comments

@c0rrzin
Copy link

c0rrzin commented Jul 28, 2014

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.

@eni9889
Copy link

eni9889 commented Dec 6, 2014

+1 on this please

@timanglade timanglade added P2 and removed backlog labels Apr 22, 2015
@bdash bdash changed the title Add JSON<->RMLObject (and RMLArray) Serializers Add JSON<->RLMObject (and RLMArray) Serializers Sep 2, 2015
@jpsim jpsim changed the title Add JSON<->RLMObject (and RLMArray) Serializers Support custom model mappings Oct 1, 2015
@jpsim
Copy link
Contributor

jpsim commented Oct 1, 2015

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.

@kylebshr
Copy link

kylebshr commented Oct 1, 2015

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 :)

@kylebshr
Copy link

kylebshr commented Oct 1, 2015

I'm having trouble implementing Decodable with Realm — @jpsim, do you have any experience with it, or an example?

@jpsim
Copy link
Contributor

jpsim commented Oct 1, 2015

Edit: the Argo link is broken if you'd like to fix that :)

Thanks, fixed.

I'm having trouble implementing Decodable with Realm — @jpsim, do you have any experience with it, or an example?

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.

@Payload-Lee
Copy link

+1

@marksbren
Copy link

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.)

@jpsim
Copy link
Contributor

jpsim commented Dec 10, 2015

@marksbren did you read my comment in #694 (comment)? Argo & Decodable work great with Realm.

@marksbren
Copy link

@jpsim thanks for the quick reply. I will try Decodable and report back

@kylebshr
Copy link

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.

@jpsim
Copy link
Contributor

jpsim commented Mar 28, 2016

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.

@JinkProject
Copy link

JinkProject commented Nov 23, 2016

@jpsim Am I seeing things, or does Realm support this now? Using initWithValue or createOrUpdateWithValue and passing it a dictionary seems to do the trick for me with no problems so far... I know it isn't as flexible as using Mantle or JSONModel, but bare-bones parsing of a single object seems to work fine.

@jpsim
Copy link
Contributor

jpsim commented Nov 23, 2016

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants