Permalink
Browse files

fixing relation updater

  • Loading branch information...
1 parent 4142663 commit a8d071cb1da585acfb8da1c4a8139d03035aec7a @mauritslamers mauritslamers committed with Jeff Pittman Oct 7, 2011
Showing with 9 additions and 6 deletions.
  1. +9 −6 store_tools.js
View
@@ -143,13 +143,16 @@ SC.mixin(ThothSC,{
hash = store.readDataHash(sK);
if(!hash) return; // we cannot update a non-existing hash
prop = hash[oppProperty];
- if(!opts.isRemove){
- if(prop instanceof Array) prop.push(recId);
- else hash[oppProperty] = recId;
+ // what are we updating here...
+ if(oppRelation.type === 'toMany'){
+ if(prop){
+ if(opts.isRemove) prop = prop.without(recId);
+ else prop.push(recId);
+ }
+ else hash[oppProperty] = opts.isRemove? []: [recId];
}
- else {
- if(prop instanceof Array) prop = prop.without(recId);
- else hash[oppProperty] = null;
+ if(oppRelation.type === 'toOne'){
+ hash[oppProperty] = opts.isRemove? null: recId;
}
store.pushRetrieve(oppRecType,relKey,hash);
}

0 comments on commit a8d071c

Please sign in to comment.