-
Notifications
You must be signed in to change notification settings - Fork 562
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
Add documentation for bundling realm files #532
Comments
Any update on this? Where should we store the realm file, and what path should we specify? |
@chaodoze On iOS you should store the file in the resources directory. You can open files directly from the resources directory in read-only mode, or copy them to the Documents directory first if you need to write to them. There is a utility method |
@alazier wow, thanks for the speedy reply. For read-only mode in the iOS resource directory, do we need to specify a path or just the filename e.g. would the following work, if test.realm were in the resource directory? |
You would need to specify the full path for the resources dir. Relative
|
Thanks @alazier, would you know how I can discover the absolute path of a On Tue, Oct 4, 2016 at 12:45 PM, Ari Lazier notifications@github.com
|
In swift/objective-c you can get this from |
hmm, what about React Native? On Tue, Oct 4, 2016 at 3:13 PM, Ari Lazier notifications@github.com wrote:
|
Doesn't seem like there is an easy way to get this from the RN apis. Might need a native module to expose this, or you can get this info in your Appdelegate. In our test files we use |
I just got this working in React Native without having to do a copyBundleRealmFiles. If you use the library react-native-fs (https://github.com/johanneslumpe/react-native-fs) you can get the bundle path using its My Realm initialiser looks like: const parksDb = new Realm({
path: RNFS.MainBundlePath + '/realm.realm',
readOnly: true
}); The database filename I baked up using the json importer example was named realm.realm and dragged into the root of the Xcode project directory of my React Native app. |
@alazier @chaodoze Hi there, Then ran:
In the constructor of my app componenent. However when I rebuild I get this error: Realm.copyBundledRealmFiles(); FAILURE: Build failed with an exception.
When I open the test2.realm file with the realm browser it opens fine. Any pointers on what I might be doing wrong?? Thanks v much for your time! |
Ok think above error was due to clearing the device data when starting the emulator. Have managed to get there now. Have documented exactly what I did here: |
@alazier It doesn't look like copyBundleRealmFiles is documented anywhere still. I think it'd be really helpful if this method was fully explained in some documentation. Also, when you guys (@martsie and @alazier) refer to the iOS resource folder, do you mean the |
@alazier I have the same question as @andersonaddo. I tried placing my pre-populated I've got it working for android (by putting it in |
No description provided.
The text was updated successfully, but these errors were encountered: