//>>built
define("dojox/data/CouchDBRestStore",["dojo","dojox","dojox/data/JsonRestStore"],function(h,g){var k=h.declare("dojox.data.CouchDBRestStore",g.data.JsonRestStore,{save:function(a){for(var c=this.inherited(arguments),d=this.service.servicePath,b=0;b<c.length;b++)(function(e,l){l.addCallback(function(f){f&&(e.__id=d+f.id,e._rev=f.rev);return f})})(c[b].content,c[b].deferred)},fetch:function(a){a.query=a.query||"_all_docs?";a.start&&(a.query=(a.query?a.query+"\x26":"")+"skip\x3d"+a.start,delete a.start);
a.count&&(a.query=(a.query?a.query+"\x26":"")+"limit\x3d"+a.count,delete a.count);return this.inherited(arguments)},_processResults:function(a){var c=a.rows;if(c){for(var d=this.service.servicePath,b=0;b<c.length;b++){var e=c[b].value;e.__id=d+c[b].id;e._id=c[b].id;e._loadObject=g.rpc.JsonRest._loader;c[b]=e}return{totalCount:a.total_rows,items:a.rows}}return{items:a}}});k.getStores=function(a){var c={};h.xhrGet({url:a+"_all_dbs",handleAs:"json",sync:!0}).addBoth(function(d){for(var b=0;b<d.length;b++)c[d[b]]=
new g.data.CouchDBRestStore({target:a+d[b],idAttribute:"_id"});return c});return c};return k});