I have a simple React Native application that's a dictionary app. It allows the user to bookmark a specific word and it's definition. So I have the two following models: Word
and Bookmark
.
Currently I have it so that the app opens a prefilled Realm database and obviously the Bookmark
is model is empty.
Bookmark
.Will the updated Realm file remove all the 'Bookmark' that the user created since the prebundled Realm file has 'Bookmark' empty?
If so do I have to have add a second Realm file that stores the unique id of the word that the user bookmarked?
You are correct that if you overwrite the Realm file every time you update then any data written to that Realm will also be overwritten. You have a few options here. First is to store the bookmarks in a separate Realm file so that they aren't overwritten when you update your dictionary. The downside to this is a little extra code/performance hit to look up bookmarked items from the dictionary Realm.
The second option is to copy individual dictionary entries into a single writable Realm on launch. This would result in a bigger performance hit at launch when updating to a new app version but would allow you to store bookmarks and entries in the same Realm file using object links.