dojox/data/CouchDBRestStore.js

  • Provides:

    • dojox.data.CouchDBRestStore
  • dojox.data.CouchDBRestStore

    • type
      Function
    • chains:
      • dojox.data.JsonRestStore: (prototype)
      • dojox.data.JsonRestStore: (call)
    • summary
  • dojox.data.CouchDBRestStore.save

    • type
      Function
    • parameters:
      • kwArgs: (typeof )
    • source: [view]
         var actions = this.inherited(arguments); // do the default save and then update for version numbers
         var prefix = this.service.servicePath;
         for(var i = 0; i < actions.length; i++){
          // need to update the item's version number after it has been committed
          (function(item,dfd){
           dfd.addCallback(function(result){
            if(result){
             item.__id = prefix + result.id; // update the object with the results of the post
             item._rev = result.rev;
            }
            return result;
           });
          })(actions[i].content,actions[i].deferred);
         }
    • summary
  • dojox.data.CouchDBRestStore.fetch

    • type
      Function
    • parameters:
      • args: (typeof )
    • source: [view]
         args.query = args.query || '_all_docs?';
         if(args.start){
          args.query = (args.query ? (args.query + '&') : '') + 'startkey=' + args.start;
          delete args.start;
         }
         if(args.count){
          args.query = (args.query ? (args.query + '&') : '') + 'limit=' + args.count;
          delete args.count;
         }
         return this.inherited(arguments);
    • summary
      This only differs from JsonRestStore in that it, will put the query string the query part of the URL and it handles start and count
  • dojox.data.CouchDBRestStore._processResults

    • type
      Function
    • parameters:
      • results: (typeof )
    • source: [view]
         var rows = results.rows;
         if(rows){
          var prefix = this.service.servicePath;
          var self = this;
          for(var i = 0; i < rows.length;i++){
           var realItem = rows[i].value;
           realItem.__id= prefix + rows[i].id;
           realItem._id= rows[i].id;
           realItem._loadObject= dojox.rpc.JsonRest._loader;
           rows[i] = realItem;
          }
          return {totalCount:results.total_rows, items:results.rows};
         }else{
          return {items:results};
         }
    • summary
  • dojox.data.CouchDBRestStore.getStores

    • type
      Function
    • parameters:
      • couchServerUrl: (typeof )
    • source: [view]
       var dfd = dojo.xhrGet({
        url: couchServerUrl+"_all_dbs",
        handleAs: "json",
        sync: true
       });
       var stores = {};
       dfd.addBoth(function(dbs){
        for(var i = 0; i < dbs.length; i++){
         stores[dbs[i]] = new dojox.data.CouchDBRestStore({target:couchServerUrl + dbs[i],idAttribute:"_id"});
        }
        return stores;
       });
       return stores;
    • summary
  • dojox.data

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary