-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
SDK end 2019-12-10
-
1817
Goals
I'm trying to delete a model without having to version it ("Pets" -> "PetsV2").
https://www.realm.io/docs/javascript/2.6.0/api/realm#deleteModel
Expected Results
Calling "deleteModel" removes an existing model and all of the objects in the model.
Actual Results
Connecting to realm via Realm Studio throws an error:
Failed while synchronizing Realm:
Bad changeset (DOWNLOAD)
Steps to Reproduce
- Spin up a ROS docker container
- Create a user "test-user" with the password "password"
- Create an index.js file and use the code example bellow (ensure realm is installed)
- Run code once with the deleteModel commented out
- Open realm in Realm Studio you should see models (you can add some data if you want)
- Uncomment deleteModel and run again
- Reopen realm in Realm Studio and you get error
Code Sample
const realm = require('realm'); const schema = [ { name: 'Pets', primaryKey: 'id', properties: { id: 'int', name: 'string' } }, { name: 'Persons', primaryKey: 'id', properties: { id: 'int', name: 'string' } } ]; const loginUrl = 'http://localhost:9080'; const realmUrl = 'realm://localhost:9080/test'; Realm.Sync.User.login(loginUrl, 'test-user', 'password') .then(user => { return Realm.open({ schema, sync: { user, realmUrl, error: (session, err) => {} } }); }) .then(realm => { realm.write(() => { realm.deleteModel('Pets'); }); });
Version of Realm and Tooling
- Realm JS SDK Version: 2.6.0
- Realm Object Server: docker (latest)
- Node or React Native: 8.6.0
- Client OS & Version: OSX (10.13.4)
- Realm Studio: 1.21.0
Running on node.js with a ROS on docker using the latest image as of May 25th 2018