~sil/u1db/jsu1db

« back to all changes in this revision

Viewing changes to u1db.js

  • Committer: stuart.langridge at canonical
  • Date: 2012-05-13 21:53:58 UTC
  • Revision ID: stuart.langridge@canonical.com-20120513215358-5wayoid8gc5959sr
oops. calling is_newer on a vectorclock was actually modifying it

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        return result    
44
44
    };
45
45
    
46
 
    this._values = function() { return values; }
 
46
    this._values = function() { 
 
47
        var clone = {};
 
48
        for (k in values) clone[k] = values[k]; // shallow copy
 
49
        return clone; 
 
50
    }
47
51
    
48
52
    var isEmptyDict = function(dict) {
49
53
        for (var k in dict) return false;
589
593
            throw (new this.Errors.InvalidDocId());
590
594
        }
591
595
        var currev = getItem("rev", doc.doc_id);
592
 
        if (currev != doc.rev && currev !== null) {
 
596
        if (currev != doc.rev) {
593
597
            throw (new this.Errors.RevisionConflict());
594
598
        }
595
599
        if (currev === null) {
625
629
        } else {
626
630
            cur_vcr = new U1DBVectorClock(cur_doc.rev);
627
631
        }
 
632
        if (this.debug_prints) print(cur_vcr, doc_vcr);
 
633
        cur_vcr.is_newer(doc_vcr);
 
634
        if (this.debug_prints) print(cur_vcr, doc_vcr);
628
635
        if (doc_vcr.is_newer(cur_vcr)) {
629
636
            /* we don't just call put_doc() here, because put_doc assumes that
630
637
               you got the doc from this db and therefore it has one of our