We have a use case with complete dynamic number of “tables”/realms and each table have complete dynamic fields (other than id field). The tables and fields can be added or removed at any time. For example, today we have table A (id, firstName, lastName), table B (id, department, description), tomorrow we will have table A (id, firstName, lastName, employeeId), table B (id, department, description, contactId), table C (id, role, permission). The data needs to be synced with Altas.
I learned that we may use DynamicRealm to support dynamic tables and schemas. but by reading this post
looks like every time we change the schema, we need to release a new Android/iOS App which is not possible in our use case. Is there a way to get it working without changing the code? For example, in Firebase or Couchbase, you don’t need to define a RealmObject in the code. The data query and sync are done by specifying the dynamic string table name/ realm name / collection name.
If your schema changes contain net new fields, this would be an additive schema change and does not require terminating and re-enabling sync. You would only need to terminate and re-enable sync for breaking schema changes ( See breaking schema changes)
Do you mind elaborating on what exactly your ideal experience is here? I am not quite sure how you would write your application code if it does not know what fields exist in the app.
One way around strict schemas is to use a RealmDictionary to store key/value pairs that the application logic can decode itself.
Additionally, it might be relevant to note that adding additional fields or tables (additive only) to the schema in App Services does not enforce that you re-release your app with those new fields. A Realm can be defined with any subset of the fields / tables in your data.
For example, in couchbase, if i want to Ad-Hoc sync with a table, I just need to pass in the table name string to the sync/replicator and the database will start sync the table. When I query the table, I can pass in a free formed SQL/SQL++ to the local database to query, without creating a RealmObject Java/Kotlin class. The SQL/SQL++ language support querying and sorting any columns in the table. Without pre-defining the columns in the Java/Kotlin class. When I add a new table or new field, I dont need to release any Java code. I just need to tell the mobile app to start sync with the new table (for example, store the list of table names that needs to be synced in a metadata database table, when adding a new table name in the metadata database table, the mobile app will start sync that new table). The SQL/SQL++ statements can be stored in database or even a text file, mobile app will download the text file to use the new SQL statements. No Java/Kotlin coding change needed, I can dynamically add/remove tables and fields.