Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-230

"deleteModel" causes "Bad changeset (DOWNLOAD)" on realm

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      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

      1. Spin up a ROS docker container
      2. Create a user "test-user" with the password "password"
      3. Create an index.js file and use the code example bellow (ensure realm is installed)
      4. Run code once with the deleteModel commented out
      5. Open realm in Realm Studio you should see models (you can add some data if you want)
      6. Uncomment deleteModel and run again
      7. 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

            Assignee:
            kenneth.geisshirt@mongodb.com Kenneth Geisshirt
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: