//>>built
define("dojox/data/CouchDBRestStore",["dojo","dojox","dojox/data/JsonRestStore"],function(g,f){var h=g.declare("dojox.data.CouchDBRestStore",f.data.JsonRestStore,{save:function(a){for(var c=this.inherited(arguments),d=this.service.servicePath,b=0;b<c.length;b++)(function(a,b){b.addCallback(function(b){b&&(a.__id=d+b.id,a._rev=b.rev);return b})})(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=f.rpc.JsonRest._loader;c[b]=e}return{totalCount:a.total_rows,items:a.rows}}return{items:a}}});h.getStores=function(a){var c={};g.xhrGet({url:a+"_all_dbs",handleAs:"json",sync:!0}).addBoth(function(d){for(var b=0;b<d.length;b++)c[d[b]]=
new f.data.CouchDBRestStore({target:a+d[b],idAttribute:"_id"});return c});return c};return h});