In Realm for ios, there is configuration for this thing through RLMRealmConfiguration.deleteRealmIfMigrationNeeded, is there any setting that we can use for realm react native?
This does not yet exist but we will add it at some point. In the meantime, you have two options:
var realm = new Realm({
schema: ...,
schemaVersion: newestSchemaVersion,
migration: function(oldRealm, newRealm) {
newRealm.deleteAll();
});
Realm.clearTestState(). Beware this method could change or be removed in a future in a release, and you probably shouldn't ship an app which is relying on this method.@alazier, I would have another use case for possibility to delete Realm feature. My plan is to use separate encrypted Realm for storing user sensitive data that is retrieved from backend. I was planning to create secret on the fly on device and store that securely (device keychain). If for some reason the secret disappears from keychain I could always recover by deleting the existing encrypted Realm, creating a new secret and creating a new Realm with this newly created secret and populating that information from backend.
@jniemin - I think what you are asking for is the same as #363 . Hopefully we can get that into a release in the near future.
@jniemin for now you can manually delete the Realm files and associated files using something like RNFS
============>your app
const realm = await getRealm();
console.log(realm.path);
====================> In Terminal
adb shell rm /data/data/com.example.package/files/default.realm
Most helpful comment
This does not yet exist but we will add it at some point. In the meantime, you have two options:
Realm.clearTestState(). Beware this method could change or be removed in a future in a release, and you probably shouldn't ship an app which is relying on this method.