-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Document Realm Best Practices #6354
Comments
|
um, what? I agree with the initial premise, but that is just not how RealmLists work. Managed RealmLists belong to the object itself. |
You cannot clone objects with primary keys. By definition there is only one of them. For all other types, simply copying it should work fine. |
Any update on this? |
I never seem to have read the initial question for some reason, but I know some things off the top of my head..
You can set the default realm configuration in If you are writing a library project, then DO NOT SET the default configuration. Then you generally either want a single instance for the UI thread based on Activity ref counting, OR you can open a Realm instance in each Activity/Fragment directly (this is documented). Background threads require their own instances, and those instances should (must?) be closed when you are no longer using them. Hopefully, one day
Compaction opens the Realm, writes a compacted copy of it, then replaces the original file; so it's best to ensure that this happens only in one process. I used to compact when the application was closing (Activity ref count reached 0 so UI thread Realm was closed). Compaction is available only if the global instance count is 0 (there is no open Realm on any threads in any processes).
This is already documented.
See https://stackoverflow.com/questions/29214236/how-to-add-1-milion-items-in-realm-correctly/38891222#38891222 or https://stackoverflow.com/a/39385985/2413303
Define a You will retrieve the data from Realm when query is complete, and all future changes so that you don't need to wonder how to keep your data in sync with the db. On background thread, open an instance, close it when it is no longer needed, and inbetween use the synchronous Realm query api.
dunno
uh, don't use encryption? 🤔 i dunno, I'm not a realm member
I wouldn't create separate Realms at all, especially now with the partial Realm api for sync (query-based Realms). Generally you want to minimize the number of links between objects and bundle them all together, because link queries are restrictive, bi-directional links can slow down change notifications, and cascade deletion is not available in the bindings.
Not sure what this means |
Hi,
I have scoured the internet for realm best practices but they are scattered and inconsistent.
It would be great if the realm team came up with a repo of gists or samples to illustrate realm best practices for java.
Some areas would be-
1)Realm Initialisation
2)Realm Compaction
3)Realm closing and app exit best practices
4)Realm bulk multi insert best practices
5)Realm fetch best practices
6)Realm backup db best practices
7)How to prevent Realm DB from getting corrupted.
8)How to model Realm DB schema's (When to create separate realms etc.)
9)Realm DB optimisation.
The text was updated successfully, but these errors were encountered: