You need to sign in to do that
Don't have an account?
Will Helling
iOS SmartStore/SmartSync creating related records offline before ids are created
We're using SmartSync and SmartStore on native iOS to create some data... The general model is that a user will go to a location, create a record of that visit and then create associated survey records that are connected to that record. My question is what is the best practices way to make sure that two objects in a parent-child relationship that have been created offline (and thus neither have an id) can be properly connected to each other on the reSync call?
My first thought was to use _soupEntryId to create a sort of temporary foreign key field between the two and then update the real foreignId field when the sync happens (and then sync again). However this has two problems:
Any help would be much appreciated.
My first thought was to use _soupEntryId to create a sort of temporary foreign key field between the two and then update the real foreignId field when the sync happens (and then sync again). However this has two problems:
- How can I get a list from SmartSync of all the objects that were updated during a sync? Do I have to just fetch every object in the database and deal with it as though it were updated?
- I haven't found a way to run an SFQuerySpec on a soup against any field that isn't Id. I see that all my custom data is stored in the record inside a field that basically just stores json, but I can't really query it directly. Would this mean I'd have to load all the objects from SmartStore and loop through them individually to match against a custom field?
Any help would be much appreciated.
I'm unsure as to the specifics of this with SmartSync, though your approach seems to be sensible. This is how we do it internally with MobileCaddy, and as a dev if you were to use our framework then you'd get full offline (including multi tier parent/child creation) out of the box. If you'd like some info here's a quick link to our guide for defining this (http://developer.mobilecaddy.net/docs/developer-guide/creating-masterdetail-lookup-relationships/);
If you'd like more info on MobileCaddy, then please feel free to ping me,
http://blog.livedoor.jp/ios_tricks/archives/4042438.html