Realm for React-native. reset database

人盡茶涼 提交于 2020-02-03 03:17:53

问题


I'am new in realm with react-native.

I change schema often, but get migration error everytime I change.

How do I reset realm database when I change schema?


回答1:


You can just delete the app from the device or the simulator to reset the Realm.




回答2:


It depends, if you are using Genymotion (for ANDROID simulation) you would use a different approach. Please note that for both approaches (XCODE & GENYMOTION) you will be reseting the simulator to factory settings...

Here are the steps I used to do this for Android :

  1. Open GenyMotion Manager

  2. Select the Virtual Device (e.g. Samung Galaxy S6).

  3. If you are on OSX. Press CMD + F (reverts to factory setting)

  4. If you are on WINDOWS. Press CTRL + F (reverts to factory setting)

  5. You can also do this by RightClick action on the item and selecting (Reset this virtual device to factory state) on your device.

  6. Enjoy!




回答3:


Using Android Emulator Genymotion

In your app

const realm = await getRealm();
console.log(realm.path);

copy the result from console.log () which will be the path of your .realm file.

In (Cmd or Terminal)

adb shell rm /data/data/com.example.package/files/default.realm


来源:https://stackoverflow.com/questions/35639286/realm-for-react-native-reset-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!