Java – realm: change the name of the migrated field
•
Java
I want to change the field name during the real DB migration
Is it correct? It takes a lot of time
The following code is my trial version, which changes the field value to summary by copying and deleting
RealmSchema schema = realm.getSchema(); schema.get("Invoice") .transform(new RealmObjectSchema.Function() { @Override public void apply(DynamicRealmObject obj) { obj.set("summary",obj.getString("value")); } }) .removeField("value");
Solution
Maybe what you need is a method: renamefield
Example:
RealmSchema schema = realm.getSchema(); schema.get("Invoice").renameField("value","summary");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码