1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    134
    Vote Rating
    1
    stefankendall is an unknown quantity at this point

      0  

    Default Unanswered: Can't remove the "many" end of a hasMany association

    Unanswered: Can't remove the "many" end of a hasMany association


    I have two stores. Store A is backed by localStorage, and has no associations.

    Store B is built in memory, and associates hasMany to Store A. It's an aggregation store.

    Ext.define('B', {
    extend: 'Ext.data.Model',
    config: {
    identifier: 'uuid',
    fields: [
    {name: 'id', type: 'string'},
    {name: 'value', type: 'int'}
    ],
    hasMany: {model: 'A', name: 'others'},
    proxy: {
    type: 'memory',
    id: 'some-id'
    }
    }
    });

    Given a store that backs B, I can't remove A records. I've tried a number of things, and everything is broken.

    First try:
    Code:
    bStore.first().others().removeAll();
    bStore.sync();
    Examining localStorage, the A records are still alive in localStorage, and are even still in aStore.

    Second try:
    Code:
    var others = bStore.first().others();
    others.removeAll();
    bStore.sync();
    others.each(function(o){aStore.remove(o);});
    aStore.sync();
    The individual proxy-uuid records are removed for aStore, but the aStore localStorage element still references the individual records.

    In localStorage:
    aProxy: uuid1,uuid2,uuid3

    But none of the associated aProxy-uuid records exist.

    Attempt 3:
    Code:
    var others = bStore.first().others();
    others.each(function(o){aStore.remove(o);});
    aStore.sync();
    This yields the same behavior as #2. What could possibly be going wrong here?

  2. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    154
    Answers
    7
    Vote Rating
    3
    coolfish is on a distinguished road

      0  

    Default


    Removing from the store is slightly different from erasing from the store. The way I handle it in my code, my models have a remove function which loops through the hasMany and calls their remove function, which I've got calling this.erase() (which will delete it from storage).

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    134
    Vote Rating
    1
    stefankendall is an unknown quantity at this point

      0  

    Default


    Can you show an example of this?

  4. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    154
    Answers
    7
    Vote Rating
    3
    coolfish is on a distinguished road

      0  

    Default


    Basically in your code you would do something like:

    Code:
    var basket = Ext.getStore("basketStore").first();
    basket.apples().each( function(apple){
     apple.erase(); // someone ate my apple.
    })
    basket.apples().removeAll();
    basket.save();
    Something like that, where your Basket class has many Apples. That'll remove the apples from the localstorage.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi