Skip to content

Commit

Permalink
(pouchdb#635) - low level method document availability support
Browse files Browse the repository at this point in the history
parseDoc and merge have to support new availability option
  • Loading branch information
neojski committed Apr 5, 2013
1 parent 4187ae3 commit ef45f7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/pouch.merge.js
Expand Up @@ -48,6 +48,12 @@ function mergeTree(in_tree1, in_tree2) {
var tree1 = item.tree1;
var tree2 = item.tree2;

if (tree1[1].status === 'available' || tree2[1].status === 'available') {
tree1[1].status = 'available';
} else {
tree1[1].status = 'missing';
}

for (var i = 0; i < tree2[2].length; i++) {
if (!tree1[2][0]) {
conflicts = 'new_leaf';
Expand Down
6 changes: 3 additions & 3 deletions src/pouch.utils.js
Expand Up @@ -79,7 +79,7 @@ var parseDoc = function(doc, newEdits) {
var nRevNum;
var newRevId;
var revInfo;
var opts = {};
var opts = {status: 'available'};
if (doc._deleted) {
opts.deleted = true;
}
Expand All @@ -96,7 +96,7 @@ var parseDoc = function(doc, newEdits) {
}
doc._rev_tree = [{
pos: parseInt(revInfo[1], 10),
ids: [revInfo[2], {}, [[newRevId, opts, []]]]
ids: [revInfo[2], {status: 'missing'}, [[newRevId, opts, []]]]
}];
nRevNum = parseInt(revInfo[1], 10) + 1;
} else {
Expand All @@ -114,7 +114,7 @@ var parseDoc = function(doc, newEdits) {
if (acc === null) {
return [x, opts, []];
} else {
return [x, {}, [acc]];
return [x, {status: 'missing'}, [acc]];
}
}, null)
}];
Expand Down

0 comments on commit ef45f7e

Please sign in to comment.