Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Bryan Kaperick
jio
Commits
a1d4c506
Commit
a1d4c506
authored
Aug 03, 2018
by
Bryan Kaperick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed behavior of allDocs with include_revisions.
parent
ee3050e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
14 deletions
+74
-14
src/jio.storage/historystorage.js
src/jio.storage/historystorage.js
+17
-14
test/jio.storage/historystorage.tests.js
test/jio.storage/historystorage.tests.js
+57
-0
test/jio.storage/tmp.txt
test/jio.storage/tmp.txt
+0
-0
No files found.
src/jio.storage/historystorage.js
View file @
a1d4c506
...
...
@@ -240,8 +240,6 @@
};
HistoryStorage
.
prototype
.
allAttachments
=
function
(
id
)
{
// XXX: allAttachments with timestamp:
// should return all non-removed attachments at this point in time
var
substorage
=
this
.
_sub_storage
,
query_obj
,
query_removed_check
,
...
...
@@ -251,6 +249,8 @@
include_revs
=
this
.
_include_revisions
,
have_seen_id
=
false
;
// id is a timestamp, and allAttachments will return attachment versions
// up-to-and-including those made at time id
if
(
include_revs
)
{
query_doc_id
=
new
SimpleQuery
({
operator
:
"
<=
"
,
...
...
@@ -290,7 +290,6 @@
]
});
options_remcheck
=
{
query
:
query_removed_check
,
select_list
:
[
"
op
"
,
"
timestamp
"
],
...
...
@@ -388,6 +387,8 @@
};
HistoryStorage
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
// In this case, id is a timestamp, so return attachment version at that
// time
if
(
this
.
_include_revisions
)
{
return
this
.
_sub_storage
.
getAttachment
(
id
,
name
)
.
push
(
undefined
,
function
(
error
)
{
...
...
@@ -467,7 +468,10 @@
};
HistoryStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
name
===
'
list
'
||
name
===
'
include
'
;
return
name
===
'
list
'
||
name
===
'
include
'
||
name
===
'
query
'
||
name
===
'
select
'
;
};
HistoryStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
...
...
@@ -477,7 +481,6 @@
if
(
options
.
sort_on
===
undefined
)
{
options
.
sort_on
=
[];
}
if
(
options
.
select_list
===
undefined
)
{
options
.
select_list
=
[];
}
options
.
query
=
jIO
.
QueryFactory
.
create
(
options
.
query
);
var
meta_options
=
{
query
:
""
,
sort_on
:
[[
"
timestamp
"
,
"
descending
"
]],
...
...
@@ -485,6 +488,10 @@
},
include_revs
=
this
.
_include_revisions
;
if
(
include_revs
)
{
// && options.query.key === "doc_id") {
meta_options
.
query
=
options
.
query
;
}
return
this
.
_sub_storage
.
allDocs
(
meta_options
)
.
push
(
function
(
results
)
{
results
=
results
.
data
.
rows
;
...
...
@@ -588,23 +595,19 @@
// Put into correct format to be passed back to query storage
.
map
(
function
(
docum
)
{
docum
.
doc
=
docum
.
value
.
doc
;
if
(
include_revs
)
{
docum
.
id
=
docum
.
value
.
timestamp
;
//docum.doc = docum.value.doc;
}
else
{
docum
.
id
=
docum
.
value
.
doc_id
;
//docum.doc = docum.value.doc;
}
delete
docum
.
value
.
doc_id
;
delete
docum
.
value
.
timestamp
;
delete
docum
.
value
.
op
;
if
(
options
.
include_docs
)
{
docum
.
doc
=
docum
.
value
.
doc
;
}
else
{
docum
.
doc
=
{};
}
docum
.
value
=
{};
docum
.
value
=
docum
.
value
.
doc
;
//docum.value = {};
return
docum
;
});
return
docs_to_query
;
...
...
test/jio.storage/historystorage.tests.js
View file @
a1d4c506
...
...
@@ -2265,6 +2265,63 @@
.
always
(
function
()
{
start
();
});
});
test
(
"
allDocs with include_revisions only one document
"
,
function
()
{
stop
();
expect
(
1
);
var
jio
=
this
.
jio
,
history
=
this
.
history
,
timestamps
,
not_history
=
this
.
not_history
;
jio
.
put
(
"
doc a
"
,
{
title
:
"
foo0
"
})
.
push
(
function
()
{
return
jio
.
put
(
"
doc a
"
,
{
title
:
"
foo1
"
});
})
.
push
(
function
()
{
return
jio
.
put
(
"
doc b
"
,
{
title
:
"
bar0
"
});
})
.
push
(
function
()
{
return
jio
.
put
(
"
doc b
"
,
{
title
:
"
bar1
"
});
})
.
push
(
function
()
{
return
not_history
.
allDocs
({
sort_on
:
[[
"
timestamp
"
,
"
ascending
"
]]
});
})
.
push
(
function
(
results
)
{
timestamps
=
results
.
data
.
rows
.
map
(
function
(
d
)
{
return
d
.
id
;
});
})
.
push
(
function
()
{
return
history
.
allDocs
({
query
:
'
doc_id: "doc a"
'
,
select_list
:
[
"
title
"
]
});
})
.
push
(
function
(
results
)
{
deepEqual
(
results
.
data
.
rows
,
[
{
id
:
timestamps
[
1
],
doc
:
{},
value
:
{
title
:
"
foo1
"
}
},
{
id
:
timestamps
[
0
],
doc
:
{},
value
:
{
title
:
"
foo0
"
}
}],
"
Only specified document revision history is returned
"
);
})
.
fail
(
function
(
error
)
{
//console.log(error);
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
Parallel edits will not break anything
"
,
function
()
{
stop
();
...
...
test/jio.storage/tmp.txt
deleted
100644 → 0
View file @
ee3050e4
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment