Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Junming
jio
Commits
60eac4f9
Commit
60eac4f9
authored
Feb 18, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jio get: "_rev" is required in the document, no longer in the options.
parent
d41b35da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
29 deletions
+22
-29
src/jio.storage/replicaterevisionstorage.js
src/jio.storage/replicaterevisionstorage.js
+9
-10
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+4
-3
test/jiotests.js
test/jiotests.js
+9
-16
No files found.
src/jio.storage/replicaterevisionstorage.js
View file @
60eac4f9
...
@@ -305,20 +305,19 @@ jIO.addStorageType('replicaterevision', function (spec, my) {
...
@@ -305,20 +305,19 @@ jIO.addStorageType('replicaterevision', function (spec, my) {
* @param {object} command The JIO command
* @param {object} command The JIO command
*/
*/
that
.
get
=
function
(
command
)
{
that
.
get
=
function
(
command
)
{
var
functions
=
{},
doc_env
,
doc
id
,
my_rev
,
revs_array
=
[];
var
functions
=
{},
doc_env
,
doc
,
my_rev
,
revs_array
=
[];
functions
.
begin
=
function
()
{
functions
.
begin
=
function
()
{
var
i
,
option
;
var
i
;
doc
id
=
command
.
getDocId
();
doc
=
command
.
cloneDoc
();
doc_env
=
my
.
env
[
docid
];
doc_env
=
my
.
env
[
doc
.
_
id
];
if
(
!
doc_env
||
!
doc_env
.
id
)
{
if
(
!
doc_env
||
!
doc_env
.
id
)
{
// document environment is not set
// document environment is not set
doc_env
=
priv
.
initEnv
(
docid
);
doc_env
=
priv
.
initEnv
(
doc
.
_
id
);
}
}
// document environment is set now
// document environment is set now
revs_array
.
length
=
priv
.
storage_list
.
length
;
revs_array
.
length
=
priv
.
storage_list
.
length
;
option
=
command
.
cloneOption
()
||
{};
my_rev
=
doc
.
_rev
;
my_rev
=
option
.
rev
;
if
(
my_rev
)
{
if
(
my_rev
)
{
functions
.
update_env
=
false
;
functions
.
update_env
=
false
;
}
}
...
@@ -326,9 +325,9 @@ jIO.addStorageType('replicaterevision', function (spec, my) {
...
@@ -326,9 +325,9 @@ jIO.addStorageType('replicaterevision', function (spec, my) {
// request all sub storages
// request all sub storages
if
(
doc_env
.
my_revisions
[
my_rev
])
{
if
(
doc_env
.
my_revisions
[
my_rev
])
{
// if my_rev exist, convert it to distant revision
// if my_rev exist, convert it to distant revision
option
.
rev
=
doc_env
.
my_revisions
[
my_rev
][
i
];
doc
.
_
rev
=
doc_env
.
my_revisions
[
my_rev
][
i
];
}
}
priv
.
send
(
"
get
"
,
i
,
doc
id
,
priv
.
clone
(
option
),
functions
.
callback
);
priv
.
send
(
"
get
"
,
i
,
doc
,
command
.
cloneOption
(
),
functions
.
callback
);
}
}
};
};
functions
.
update_env
=
true
;
functions
.
update_env
=
true
;
...
@@ -349,7 +348,7 @@ jIO.addStorageType('replicaterevision', function (spec, my) {
...
@@ -349,7 +348,7 @@ jIO.addStorageType('replicaterevision', function (spec, my) {
}
else
{
}
else
{
// the document revision is unknown
// the document revision is unknown
if
(
functions
.
update_env
===
true
)
{
if
(
functions
.
update_env
===
true
)
{
my_rev
=
priv
.
generateNextRevision
(
0
,
docid
);
my_rev
=
priv
.
generateNextRevision
(
0
,
doc
.
_
id
);
doc_env
.
my_revisions
[
my_rev
]
=
revs_array
;
doc_env
.
my_revisions
[
my_rev
]
=
revs_array
;
doc_env
.
distant_revisions
[
response
.
_rev
||
"
unique_
"
+
index
]
=
doc_env
.
distant_revisions
[
response
.
_rev
||
"
unique_
"
+
index
]
=
my_rev
;
my_rev
;
...
...
src/jio.storage/revisionstorage.js
View file @
60eac4f9
...
@@ -923,7 +923,7 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -923,7 +923,7 @@ jIO.addStorageType('revision', function (spec, my) {
if
(
option
.
max_retry
===
0
)
{
if
(
option
.
max_retry
===
0
)
{
option
.
max_retry
=
3
;
option
.
max_retry
=
3
;
}
}
prev_rev
=
command
.
get
Option
(
"
rev
"
);
prev_rev
=
command
.
get
DocInfo
(
"
_
rev
"
);
if
(
typeof
prev_rev
===
"
string
"
)
{
if
(
typeof
prev_rev
===
"
string
"
)
{
if
(
!
priv
.
checkRevisionFormat
(
prev_rev
))
{
if
(
!
priv
.
checkRevisionFormat
(
prev_rev
))
{
that
.
error
({
that
.
error
({
...
@@ -941,7 +941,8 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -941,7 +941,8 @@ jIO.addStorageType('revision', function (spec, my) {
that
.
addJob
(
that
.
addJob
(
"
get
"
,
"
get
"
,
priv
.
substorage
,
priv
.
substorage
,
command
.
getDocId
()
+
priv
.
doctree_suffix
,
{
"
_id
"
:
command
.
getDocId
()
+
priv
.
doctree_suffix
,
"
_rev
"
:
command
.
getDocInfo
(
"
_rev
"
)},
option
,
option
,
function
(
response
)
{
function
(
response
)
{
doctree
=
response
;
doctree
=
response
;
...
@@ -982,7 +983,7 @@ jIO.addStorageType('revision', function (spec, my) {
...
@@ -982,7 +983,7 @@ jIO.addStorageType('revision', function (spec, my) {
that
.
addJob
(
that
.
addJob
(
"
get
"
,
"
get
"
,
priv
.
substorage
,
priv
.
substorage
,
docid
,
{
"
_id
"
:
docid
,
"
_rev
"
:
command
.
getDocInfo
(
"
_rev
"
)}
,
option
,
option
,
function
(
response
)
{
function
(
response
)
{
var
attmt
;
var
attmt
;
...
...
test/jiotests.js
View file @
60eac4f9
...
@@ -1800,9 +1800,8 @@ test ("Get", function(){
...
@@ -1800,9 +1800,8 @@ test ("Get", function(){
// get inexistent specific document
// get inexistent specific document
o
.
spy
(
o
,
"
status
"
,
404
,
"
Get document (inexistent specific revision)
"
);
o
.
spy
(
o
,
"
status
"
,
404
,
"
Get document (inexistent specific revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
get1
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
get1
"
,
"
_rev
"
:
"
1-rev0
"
},
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
"
1-rev0
"
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
@@ -1815,9 +1814,8 @@ test ("Get", function(){
...
@@ -1815,9 +1814,8 @@ test ("Get", function(){
}];
}];
o
.
doc_myget2_cloned
[
"
_conflicts
"
]
=
[
"
1-rev1
"
];
o
.
doc_myget2_cloned
[
"
_conflicts
"
]
=
[
"
1-rev1
"
];
o
.
spy
(
o
,
"
value
"
,
o
.
doc_myget2_cloned
,
"
Get document (specific revision)
"
);
o
.
spy
(
o
,
"
value
"
,
o
.
doc_myget2_cloned
,
"
Get document (specific revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
get1
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
get1
"
,
"
_rev
"
:
"
1-rev2
"
},
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
"
1-rev2
"
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
@@ -1842,17 +1840,15 @@ test ("Get", function(){
...
@@ -1842,17 +1840,15 @@ test ("Get", function(){
// get inexistent attachment specific rev
// get inexistent attachment specific rev
o
.
spy
(
o
,
"
status
"
,
404
,
"
Get inexistent attachment (specific revision)
"
);
o
.
spy
(
o
,
"
status
"
,
404
,
"
Get inexistent attachment (specific revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
get1/get2
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
get1/get2
"
,
"
_rev
"
:
"
1-rev1
"
},
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
"
1-rev1
"
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
// get attachment specific rev
// get attachment specific rev
o
.
spy
(
o
,
"
value
"
,
"
abc
"
,
"
Get attachment (specific revision)
"
);
o
.
spy
(
o
,
"
value
"
,
"
abc
"
,
"
Get attachment (specific revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
get1/get2
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
get1/get2
"
,
"
_rev
"
:
"
1-rev2
"
},
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
"
1-rev2
"
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
@@ -1860,9 +1856,8 @@ test ("Get", function(){
...
@@ -1860,9 +1856,8 @@ test ("Get", function(){
o
.
doc_myget2_cloned
[
"
_attachments
"
]
=
o
.
attmt_myget2
;
o
.
doc_myget2_cloned
[
"
_attachments
"
]
=
o
.
attmt_myget2
;
o
.
spy
(
o
,
"
value
"
,
o
.
doc_myget2_cloned
,
o
.
spy
(
o
,
"
value
"
,
o
.
doc_myget2_cloned
,
"
Get document which have an attachment (specific revision)
"
);
"
Get document which have an attachment (specific revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
get1
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
get1
"
,
"
_rev
"
:
"
1-rev2
"
},
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
"
1-rev2
"
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
@@ -2132,9 +2127,9 @@ test ("Scenario", function(){
...
@@ -2132,9 +2127,9 @@ test ("Scenario", function(){
o
.
doc
.
_revs_info
=
[{
"
rev
"
:
o
.
rev
,
"
status
"
:
"
available
"
}];
o
.
doc
.
_revs_info
=
[{
"
rev
"
:
o
.
rev
,
"
status
"
:
"
available
"
}];
o
.
spy
(
o
,
"
value
"
,
o
.
doc
,
"
And, on this new tab, I load the document,
"
+
o
.
spy
(
o
,
"
value
"
,
o
.
doc
,
"
And, on this new tab, I load the document,
"
+
"
and my application keep the revision in memory
"
);
"
and my application keep the revision in memory
"
);
o
.
jio2
.
get
({
"
_id
"
:
"
sample1
"
},
{
o
.
jio2
.
get
({
"
_id
"
:
"
sample1
"
,
"
_rev
"
:
o
.
rev
},
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
o
.
rev
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
// MODFIY the 2nd version
// MODFIY the 2nd version
...
@@ -2431,11 +2426,10 @@ module ("JIO Replicate Revision Storage");
...
@@ -2431,11 +2426,10 @@ module ("JIO Replicate Revision Storage");
"
_revs_info
"
:
[{
"
rev
"
:
"
1-2
"
,
"
status
"
:
"
available
"
}],
"
_revs_info
"
:
[{
"
rev
"
:
"
1-2
"
,
"
status
"
:
"
available
"
}],
"
_conflicts
"
:
[
"
1-1
"
]
"
_conflicts
"
:
[
"
1-1
"
]
},
"
Get the previous document (with revision)
"
);
},
"
Get the previous document (with revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
doc1
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
doc1
"
,
"
_rev
"
:
"
1-2
"
},
{
"
conflicts
"
:
true
,
"
conflicts
"
:
true
,
"
revs
"
:
true
,
"
revs
"
:
true
,
"
revs_info
"
:
true
,
"
revs_info
"
:
true
,
"
rev
"
:
"
1-2
"
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
@@ -2448,11 +2442,10 @@ module ("JIO Replicate Revision Storage");
...
@@ -2448,11 +2442,10 @@ module ("JIO Replicate Revision Storage");
"
_revs_info
"
:
[{
"
rev
"
:
o
.
specific_rev
,
"
status
"
:
"
available
"
}],
"
_revs_info
"
:
[{
"
rev
"
:
o
.
specific_rev
,
"
status
"
:
"
available
"
}],
"
_conflicts
"
:
[
o
.
specific_rev_conflict
]
"
_conflicts
"
:
[
o
.
specific_rev_conflict
]
},
"
Get a previous document (with local storage revision)
"
);
},
"
Get a previous document (with local storage revision)
"
);
o
.
jio
.
get
({
"
_id
"
:
"
doc1
"
},
{
o
.
jio
.
get
({
"
_id
"
:
"
doc1
"
,
"
_rev
"
:
o
.
specific_rev
},
{
"
conflicts
"
:
true
,
"
conflicts
"
:
true
,
"
revs
"
:
true
,
"
revs
"
:
true
,
"
revs_info
"
:
true
,
"
revs_info
"
:
true
,
"
rev
"
:
o
.
specific_rev
},
o
.
f
);
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
...
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