1 Reply Latest reply on Jul 2, 2013 12:21 AM by vinothini balakrishnan

    How do I sync a parent child relationship?

      I was able to follow the tutorials and create a one model rhodes application with a one adapter rhoconnect application to sync to the back end.

      In this scenario I was able to create the record in the backend and have the backend create my id and update the local record with this id.


      Now I need to be able to add a second model that is a child of the first model.

      There is a one to many relationship between the first model and the second model.

      In this scenario while offline I can create the first model and several of the second models and tie them together with the temporay id rhodes creates.

      Now the issues I have run into are when I try to sync this data to the backend.

      When the first model is synced the backend database returns an id and I update the local record with this id.

      This causes a problem when the second model syncs because now the temporary id that was used to tie the first model with the second model no longer exists.

      Now I have orphaned second model records.


      How do I resolve this?

        • Re: How do I sync a parent child relationship?
          vinothini balakrishnan

          Hi Tom,

          When you sync the parent model, send the temporary id created by Rhodes in the callback parameter after you get the id returned from the back end you are updating the

          local  record with this id, in the sync callback method find the child records whose id is the temporary id, that you get from the callback method and update those records with the new id.


          Vinothini B

          Spritle Software