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

Core Data to React Native Realm #584

Closed
edo1493 opened this issue Sep 2, 2016 · 7 comments
Closed

Core Data to React Native Realm #584

edo1493 opened this issue Sep 2, 2016 · 7 comments
Labels

Comments

@edo1493
Copy link

edo1493 commented Sep 2, 2016

Hi guys,
I do have an existing iOS native app that is running on Core Data. I was wondering if it was possible to port, in some way, the whole Core Data data model to React Native Realm, as I am re-writing the app in React Native. This would help me a lot since I also need to ship it on Android (and I want to have the same data model on both).

I haven't found anything related to this, apart from a migration from Core Data to Realm on the native side.

@alazier
Copy link
Contributor

alazier commented Sep 2, 2016

At this point you will need to write new ObjectSchema objects for each Core Data type you want to support. Unless you have a huge number of objects this shouldn't be too difficult to do by hand. It may be possible to write tools to generate the JSON schema automatically but we haven't spent any time working on this.

@edo1493
Copy link
Author

edo1493 commented Sep 7, 2016

@alazier so, in theory I just have to re-define the objects (on the React Native side) as they are defined in Core Data (objective-c side) and I will be able to use the existing data and add new one?

My main issue is in not understanding if Core Data (objective-c) -> Realm (React Native) is possible. When it seems pretty straightforward on the native side (https://realm.io/news/migrating-from-core-data-to-realm/).

@alazier
Copy link
Contributor

alazier commented Sep 8, 2016

You could migrate to Realm using the cocoa api - as long as your schema is identical, realms created using the cocoa api will be usable using the React-Native binding. That is probably the most straightforward approach if you want to migrate over existing data.

@edo1493
Copy link
Author

edo1493 commented Sep 8, 2016

This means if I re-write the schema with Realm React Native and query it, I should be able to see data if I have correctly migrated the Core Data to Realm Objective-C, right? Sorry If I ask again, just want to be sure.

The cocoa API migration didn't seem a problem, I wasn't sure if I could use the data with the RN binding.

@edo1493
Copy link
Author

edo1493 commented Sep 9, 2016

@alazier ?

@bmunkholm
Copy link
Contributor

All Realm products can share files, so you can generate data from ObjC and read it in RN - no problem as long as you obviously match the models.

@edo1493
Copy link
Author

edo1493 commented Sep 13, 2016

Okay, perfect. I didn't know that.

@alazier alazier closed this as completed Sep 13, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants