realm-swift
realm-swift copied to clipboard
Request: RealmConfiguration should have initial data transaction option
Goals
Realm-Java has a very nice method in RealmConfiguration which lets me set up an "initial" data transaction, where I can add all the objects that I need, it is only triggered the first time that I access the realm instance, and never after that.
Expected Results
Realm-Cocoa should also have this option in RealmConfiguration so that we can set up code based initial data population, instead of having to depend on a separate, bundled Realm database.
Thanks a lot for the suggestion @dhiraj! I've added this to our backlog so we can review it later. :)
Since RLMRealm
has an isEmpty
property, I don't see us adding this any time soon since it's just as easy to use that to accomplish what you'd like.
@jpsim I'm not sure isEmpty
is a total replacement for this feature. Imagine an app that launches populated sample data (by checking isEmpty
). If the user deletes all the sample data and relaunches the app, it will again be repopulated with sample data.
That said, it's still possible to accomplish the desired effect by inserting some singleton state object after first launch, though this is a bit more tricky for users.
True. There's also the matter of requiring an inter-process lock to avoid race conditions, I just don't think this should be prioritized higher than it is now is all.