Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
4ad887e3
Commit
4ad887e3
authored
Dec 05, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revisionstorage.js upgraded to JIO v2
parent
f51d8d5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+24
-17
No files found.
src/jio.storage/revisionstorage.js
View file @
4ad887e3
...
...
@@ -293,6 +293,7 @@
};
priv
.
send
=
function
(
command
,
method
,
doc
,
option
,
callback
)
{
var
storage
=
command
.
storage
(
priv
.
sub_storage
);
function
onSuccess
(
success
)
{
callback
(
undefined
,
success
);
}
...
...
@@ -300,11 +301,9 @@
callback
(
err
,
undefined
);
}
if
(
method
===
'
allDocs
'
)
{
command
.
storage
(
priv
.
sub_storage
).
allDocs
(
option
).
then
(
onSuccess
,
onError
);
storage
.
allDocs
(
option
).
then
(
onSuccess
,
onError
);
}
else
{
command
.
storage
(
priv
.
sub_storage
)[
method
](
doc
,
option
).
then
(
onSuccess
,
onError
);
storage
[
method
](
doc
,
option
).
then
(
onSuccess
,
onError
);
}
};
...
...
@@ -399,7 +398,15 @@
priv
.
getRevisionTree
=
function
(
command
,
doc
,
option
,
callback
)
{
doc
=
priv
.
clone
(
doc
);
doc
.
_id
=
doc
.
_id
+
priv
.
doc_tree_suffix
;
priv
.
get
(
command
,
doc
,
option
,
callback
);
priv
.
get
(
command
,
doc
,
option
,
function
(
err
,
response
)
{
if
(
err
)
{
return
callback
(
err
,
response
);
}
if
(
response
.
data
&&
response
.
data
.
children
)
{
response
.
data
.
children
=
JSON
.
parse
(
response
.
data
.
children
);
}
return
callback
(
err
,
response
);
});
};
priv
.
getAttachmentList
=
function
(
command
,
doc
,
option
,
callback
)
{
...
...
@@ -441,7 +448,7 @@
}
}
if
(
count
===
0
)
{
callback
(
undefined
,
[]
);
callback
(
undefined
,
{
"
data
"
:
[]}
);
}
};
...
...
@@ -481,14 +488,15 @@
priv
.
putDocumentTree
=
function
(
command
,
doc
,
option
,
doc_tree
,
callback
)
{
doc_tree
=
priv
.
clone
(
doc_tree
);
doc_tree
.
_id
=
doc
.
_id
+
priv
.
doc_tree_suffix
;
if
(
doc_tree
.
children
)
{
doc_tree
.
children
=
JSON
.
stringify
(
doc_tree
.
children
);
}
priv
.
put
(
command
,
doc_tree
,
option
,
callback
);
};
priv
.
notFoundError
=
function
(
message
,
reason
)
{
return
{
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
status
"
:
"
not_found
"
,
"
message
"
:
message
,
"
reason
"
:
reason
};
...
...
@@ -496,9 +504,7 @@
priv
.
conflictError
=
function
(
message
,
reason
)
{
return
{
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
,
"
error
"
:
"
conflict
"
,
"
status
"
:
"
conflict
"
,
"
message
"
:
message
,
"
reason
"
:
reason
};
...
...
@@ -539,7 +545,7 @@
return
onEnd
(
err
,
undefined
);
}
}
doc_tree
=
response
.
data
||
priv
.
newDocTree
();
doc_tree
=
(
response
&&
response
.
data
)
||
priv
.
newDocTree
();
if
(
specific_parameter
.
get
||
specific_parameter
.
getAttachment
)
{
if
(
!
doc
.
_rev
)
{
winner_info
=
priv
.
getWinnerRevsInfo
(
doc_tree
);
...
...
@@ -600,7 +606,7 @@
"
missing
"
),
undefined
);
}
priv
.
putDocument
(
doc
,
option
,
callback
.
putDocument
);
priv
.
putDocument
(
command
,
doc
,
option
,
callback
.
putDocument
);
};
callback
.
getDocument
=
function
(
err
,
res_doc
)
{
var
k
,
conflicts
;
...
...
@@ -619,12 +625,13 @@
"
missing
"
),
undefined
);
}
res_doc
=
{};
res_doc
=
{
"
data
"
:{}
};
}
else
{
err
.
message
=
"
Cannot get document
"
;
return
onEnd
(
err
,
undefined
);
}
}
res_doc
=
res_doc
.
data
;
if
(
specific_parameter
.
get
)
{
res_doc
.
_id
=
doc
.
_id
;
res_doc
.
_rev
=
doc
.
_rev
;
...
...
@@ -665,6 +672,7 @@
err
.
message
=
"
Cannot get attachment
"
;
return
onEnd
(
err
,
undefined
);
}
res_list
=
res_list
.
data
;
attachment_list
=
res_list
||
[];
if
(
specific_parameter
.
getAttachment
)
{
// getting specific attachment
...
...
@@ -745,7 +753,6 @@
return
onEnd
(
err
,
undefined
);
}
response_object
=
{
"
ok
"
:
true
,
"
id
"
:
doc
.
_id
,
"
rev
"
:
doc
.
_rev
};
...
...
@@ -784,7 +791,7 @@
if
(
err
)
{
return
command
.
error
(
err
);
}
command
.
success
({
"
id
"
:
response
.
id
});
command
.
success
({
"
id
"
:
response
.
id
,
"
rev
"
:
response
.
rev
});
}
);
};
...
...
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