Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    5
    Vote Rating
    0
    masterof0 is on a distinguished road

      0  

    Default Ext and CouchDB

    Ext and CouchDB


    I am not really sure if this is the best place to present this, or if it is even deemd a bug, but there is definitely a data handling issue between CouchDB and JsonWriter. Basically what it comes down to is Ext presents data based on the root id and the defined fields.

    ex {"rows" : {"key1" : "value1, "key2" : "value2"}

    Since CouchDB manages documents, and not records, it looks for a _rev key/value to ensure there is not a conflict between two people writing to the same doc at a time. The value of this field has to match the current revision id before Couch will update the document.

    I have come up with a quick fix to the JsonWriter class that resolves this issue for a single update, but needs some tweaking to support multiple updates to the same record without refreshing the page. I am sure there is a better way to achieve this, but thought I would throw this out there.

    Code:
    Ext.data.JsonWriter = Ext.extend(Ext.data.DataWriter, {
    
        couch : false,
        
        encode : true,
        
        encodeDelete: false,
        
        constructor : function(config){
            Ext.data.JsonWriter.superclass.constructor.call(this, config);    
        },
    
        
        render : function(params, baseParams, data) {
            if (this.encode === true) {
                
                Ext.apply(params, baseParams);
                params[this.meta.root] = Ext.encode(data);
            } else {
                
                var jdata = Ext.apply({}, baseParams);
                jdata[this.meta.root] = data;
                // Add _rev to json array to support CouchDB
                if (data._rev && this.couch === true) {
                    jdata._rev = data._rev;
                }
                params.jsonData = jdata;
            }
        },
        
        createRecord : function(rec) {
           return this.toHash(rec);
        },
        
        updateRecord : function(rec) {
            return this.toHash(rec);
        },
        
        destroyRecord : function(rec){
            if(this.encodeDelete){
                var data = {};
                data[this.meta.idProperty] = rec.id;
                return data;
            }else{
                return rec.id;
            }
        }
    });

  2. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    74
    Vote Rating
    3
    shaneavery is on a distinguished road

      0  

    Default Tutorial series finally released - MVC CRUD App built with ExtJS-4 and CouchDB

    Tutorial series finally released - MVC CRUD App built with ExtJS-4 and CouchDB


    Hello,

    I finally completed a Tutorial series that demonstrates how to use the new MVC pattern and associations classes of ExtJS-4 with CouchDB by means of Peter Muller's software patch. The series includes an introductory write-up, several video screencasts, and some other resources. You can read all about it and view the screencasts here:

    http://averydc.com/ee/index.php/blog...ng_combination

    I probably made some mistakes and perhaps mis-spoke here and there, so please feel free to offer constructive criticism. You can post comments on my Blog post. My intention is to help both CouchDB users and/or ExtJS-4 users get a jump start with building an MVC client/server CRUD application using document databases as an alternative to relational databases.

    Peter Muller created a software patch for ExtJS-4 and Sencha Touch that makes working with de-normalized databases much easier. I find it is a very maintainable solution for me. If Peter's software patch is something that will work for you, please request from Sencha devs that the patch be integrated into an official release of ExtJS-4 and Sencha Touch in the future. The thread is being watched by Ed Spencer, as he is curious to see the demand. To add your voice, get the patch, or report issues, please post a comment in Peter's thread here:

    http://www.sencha.com/forum/showthre...ighlight=couch

    Hope this fills a need... Thanks.

Similar Threads

  1. CouchDB
    By spgarbet in forum Community Discussion
    Replies: 13
    Last Post: 27 Sep 2011, 4:11 PM
  2. using extjs instead of jquery for couchdb
    By whimsica in forum Community Discussion
    Replies: 6
    Last Post: 13 Jul 2011, 10:47 PM
  3. couchDB
    By mnask79 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 13 Jul 2011, 11:20 AM
  4. ExtJS / CouchDB integration
    By stevestorey in forum Ext 3.x: User Extensions and Plugins
    Replies: 6
    Last Post: 13 Jul 2011, 11:15 AM

Thread Participants: 1