coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.72k stars 240 forks source link

Possible bug and better uri handling in persistence.sync.js #122

Open aurzola opened 11 years ago

aurzola commented 11 years ago

lines 184 and 185 throws group var undefined:

      for(var id=0;id<group.length;id++){
        idVals.push( persistence.typeMapper.entityIdToDbId(group[id]));
      }

also: i'm writting one java servlet for server component that responds to multiples types of entites the uri has a parameter for the entity name but the client /getUpdates?entity=Task, so i suggest the call in synchronize to be :

persistence.sync.getJSON(uri + (uri.indexOf("?")==-1 ? "?" : "&") + 'since=' + lastServerSyncTime, function(result) ...

the same applies to encodeUrlObj:

function encodeUrlObj(uri,obj) { var parts = []; for(var k in obj) { if(obj.hasOwnProperty(k)) { parts.push(encodeURI(k)+"="+encodeURI(obj[k])); } } return (uri.indexOf("?")==-1 ? "?" : "&") + parts.join("&"); }

thank you