PDA

View Full Version : Only one of my models is saving.



stefankendall
25 Jan 2012, 8:16 PM
I have a handful of models, but only one seems to be doing any sort of syncstorage saving. In the following example, "LiftCompletion" saves, but "Lift" does not. I see "getUpdates()" in the console when I call sync on its store, but I don't see the flood of information that syncing LiftCompletion gives, and when I refresh my browser (testing locally), only the LiftCompletion is saved.

Why might this be happening? I can't go forward until all my models sync.


Ext.regModel('Lift', {
fields:[
{name:'id', type:'integer'},
{name:'name', type:'string'},
{name:'propertyName', type:'string'},
{name:'max', type:'float'},
{name:'cycleIncrease', type:'float'}
],
validations:[
{field:'propertyName', type:'custom', message:'nonunique',
fn:wendler.models.Lift.uniquePropertyNameValidation},
{field:'propertyName', type:'presence'},
{field:'max', type:'format', matcher:/^\d\d*$/, message:'Must enter a max'},
{field:'max', type:'presence'},
{field:'cycleIncrease', type:'presence'}
],
proxy:{
key: 'stefankendall',
type:'syncstorage',
id:'lift-proxy'
}
});




Ext.regModel('LiftCompletion', {
fields:[
{name:'id', type:'integer'},
{name:'liftPropertyName', type:'string'},
{name:'week', type:'integer'},
{name:'completed', type:'boolean'}
],
proxy:{
key: 'stefankendall',
type:'syncstorage',
id:'lift-completion-proxy'
}
});

Möhre
26 Jan 2012, 1:54 AM
Which Sencha Touch Version? Which IO-SDK?

I would test...
- to strip off the validations
- a different proxy-id (change name)

merrells
26 Jan 2012, 5:08 PM
Hello,

I good first test is to get your models working with the regular local store first. Try that.

The only think in your code that I noticed might be a problem is the declaration of 'id' as an integer. That might cause problems. 'string' would be better.

John

stefankendall
26 Jan 2012, 7:57 PM
Switching the IDs worked, but why? Is there any way to clear a corrupted store? I'd like to be able to migrate existing localStorage data for each user using the localstorage proxy, although localstorage seems broken in 1.2.0-alpha-whatever-sync version.

If I switch to 1.2.0-alpha..., and only make that change, my application is broken due to random localstorage breakage.

Is there a better way to use Sencha IO with 1.1.1?

merrells
26 Jan 2012, 8:14 PM
> Switching the IDs worked, but why?

Sync uses IDs that are multi-part (x-y-z), so are saved as strings.
By declaring it an integer it was probably truncating the ID.

> Is there a better way to use Sencha IO with 1.1.1?

No, unfortunately not. Only the very first alpha releases of SIO were
targeted to ST1. The current release works with ST2 PR2. We'll be
releasing an update to SIO once ST2 ships.

John

stefankendall
26 Jan 2012, 8:20 PM
I've switched all my ids to strings, and I might be able to handle the data migration manually by inspecting localStorage. This sucks, but it's doable.

Now, when I change data and reload locally, data is persisted.

However, when I clear my cache and reload, all my stores' load events fire with a count of 0, which causes default data to start to be written. Some of my stores then start throwing errors like this:


Error: Record has already been created. {"liftPropertyName":"squat","week":1,"completed":false,"id":"0-33779868","_state":{"_oid":"0-33779868","liftPropertyName":"0-33779868-1","week":"0-33779868-2","completed":"0-33779868-3","id":"0-33779868-4"},"_oid":"0-33779868","_ts":"","_ref":"","_model":""}

Why is this happening? I would expect the load events to *not* fire until updates have been retrieved.

merrells
27 Jan 2012, 5:49 AM
Hello,

I'm sorry but that problem doesn't sound familiar to me, and off the top of my head I'm not sure why that would ever happen.

ST1 + SIO is a long time ago for us, and we're working hard to keep pace with ST2.

John

stefankendall
27 Jan 2012, 6:04 AM
I understand. My main blocker for not using ST2 was localstorage breakage. If sync storage works, I can navigate the other bugs.

What version of IO and ST2 should I migrate to? My choices are use Sencha IO or build it myself, and if I want to confidently release a fix this weekend, a migration to ST2 is more viable.

One way or another, I'm resolving the "I lost all my data and you're terrible" emails. :)

merrells
27 Jan 2012, 6:11 AM
> I understand. My main blocker for not using ST2 was localstorage breakage.
> If sync storage works, I can navigate the other bugs.

syncstorage uses localstorage, so it's not an either/or choice.

localstorage in ST2 PR4 is better than either ST1 or ST2 PR2, but there are still a few problems, which will be resolved in the next release of ST2.

> What version of IO and ST2 should I migrate to?

The best combination right now is ST2 PR2 + SIO b3.
But, you will find plenty of UI related issues in PR2.

> My choices are use Sencha IO or build it myself, and if I want to confidently release
> a fix this weekend, a migration to ST2 is more viable.

Tricky.

> One way or another, I'm resolving the "I lost all my data and you're terrible" emails. :)

Yeah, not nice. SIO is intended to make user's data more durable. We're just not quite done yet...

John

stefankendall
27 Jan 2012, 6:18 AM
I have faith you'll get there. Beta means bleeding all over the product, I guess.

I'll try PR2 and wait for the beta. I tried to migrate to ST2 once already, so I think I can reliably navigate the UI issues.

Hopefully the migration tonight goes well, eh.

Möhre
30 Jan 2012, 9:31 AM
id: has it to be integer or string?

unclear @ Sencha : http://www.sencha.com/forum/showthread.php?177628-LocalStorage-non-integer-id