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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
jio
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
Show 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 @@
...
@@ -293,6 +293,7 @@
};
};
priv
.
send
=
function
(
command
,
method
,
doc
,
option
,
callback
)
{
priv
.
send
=
function
(
command
,
method
,
doc
,
option
,
callback
)
{
var
storage
=
command
.
storage
(
priv
.
sub_storage
);
function
onSuccess
(
success
)
{
function
onSuccess
(
success
)
{
callback
(
undefined
,
success
);
callback
(
undefined
,
success
);
}
}
...
@@ -300,11 +301,9 @@
...
@@ -300,11 +301,9 @@
callback
(
err
,
undefined
);
callback
(
err
,
undefined
);
}
}
if
(
method
===
'
allDocs
'
)
{
if
(
method
===
'
allDocs
'
)
{
command
.
storage
(
priv
.
sub_storage
).
allDocs
(
option
).
storage
.
allDocs
(
option
).
then
(
onSuccess
,
onError
);
then
(
onSuccess
,
onError
);
}
else
{
}
else
{
command
.
storage
(
priv
.
sub_storage
)[
method
](
doc
,
option
).
storage
[
method
](
doc
,
option
).
then
(
onSuccess
,
onError
);
then
(
onSuccess
,
onError
);
}
}
};
};
...
@@ -399,7 +398,15 @@
...
@@ -399,7 +398,15 @@
priv
.
getRevisionTree
=
function
(
command
,
doc
,
option
,
callback
)
{
priv
.
getRevisionTree
=
function
(
command
,
doc
,
option
,
callback
)
{
doc
=
priv
.
clone
(
doc
);
doc
=
priv
.
clone
(
doc
);
doc
.
_id
=
doc
.
_id
+
priv
.
doc_tree_suffix
;
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
)
{
priv
.
getAttachmentList
=
function
(
command
,
doc
,
option
,
callback
)
{
...
@@ -441,7 +448,7 @@
...
@@ -441,7 +448,7 @@
}
}
}
}
if
(
count
===
0
)
{
if
(
count
===
0
)
{
callback
(
undefined
,
[]
);
callback
(
undefined
,
{
"
data
"
:
[]}
);
}
}
};
};
...
@@ -481,14 +488,15 @@
...
@@ -481,14 +488,15 @@
priv
.
putDocumentTree
=
function
(
command
,
doc
,
option
,
doc_tree
,
callback
)
{
priv
.
putDocumentTree
=
function
(
command
,
doc
,
option
,
doc_tree
,
callback
)
{
doc_tree
=
priv
.
clone
(
doc_tree
);
doc_tree
=
priv
.
clone
(
doc_tree
);
doc_tree
.
_id
=
doc
.
_id
+
priv
.
doc_tree_suffix
;
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
.
put
(
command
,
doc_tree
,
option
,
callback
);
};
};
priv
.
notFoundError
=
function
(
message
,
reason
)
{
priv
.
notFoundError
=
function
(
message
,
reason
)
{
return
{
return
{
"
status
"
:
404
,
"
status
"
:
"
not_found
"
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
message
,
"
message
"
:
message
,
"
reason
"
:
reason
"
reason
"
:
reason
};
};
...
@@ -496,9 +504,7 @@
...
@@ -496,9 +504,7 @@
priv
.
conflictError
=
function
(
message
,
reason
)
{
priv
.
conflictError
=
function
(
message
,
reason
)
{
return
{
return
{
"
status
"
:
409
,
"
status
"
:
"
conflict
"
,
"
statusText
"
:
"
Conflict
"
,
"
error
"
:
"
conflict
"
,
"
message
"
:
message
,
"
message
"
:
message
,
"
reason
"
:
reason
"
reason
"
:
reason
};
};
...
@@ -539,7 +545,7 @@
...
@@ -539,7 +545,7 @@
return
onEnd
(
err
,
undefined
);
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
(
specific_parameter
.
get
||
specific_parameter
.
getAttachment
)
{
if
(
!
doc
.
_rev
)
{
if
(
!
doc
.
_rev
)
{
winner_info
=
priv
.
getWinnerRevsInfo
(
doc_tree
);
winner_info
=
priv
.
getWinnerRevsInfo
(
doc_tree
);
...
@@ -600,7 +606,7 @@
...
@@ -600,7 +606,7 @@
"
missing
"
"
missing
"
),
undefined
);
),
undefined
);
}
}
priv
.
putDocument
(
doc
,
option
,
callback
.
putDocument
);
priv
.
putDocument
(
command
,
doc
,
option
,
callback
.
putDocument
);
};
};
callback
.
getDocument
=
function
(
err
,
res_doc
)
{
callback
.
getDocument
=
function
(
err
,
res_doc
)
{
var
k
,
conflicts
;
var
k
,
conflicts
;
...
@@ -619,12 +625,13 @@
...
@@ -619,12 +625,13 @@
"
missing
"
"
missing
"
),
undefined
);
),
undefined
);
}
}
res_doc
=
{};
res_doc
=
{
"
data
"
:{}
};
}
else
{
}
else
{
err
.
message
=
"
Cannot get document
"
;
err
.
message
=
"
Cannot get document
"
;
return
onEnd
(
err
,
undefined
);
return
onEnd
(
err
,
undefined
);
}
}
}
}
res_doc
=
res_doc
.
data
;
if
(
specific_parameter
.
get
)
{
if
(
specific_parameter
.
get
)
{
res_doc
.
_id
=
doc
.
_id
;
res_doc
.
_id
=
doc
.
_id
;
res_doc
.
_rev
=
doc
.
_rev
;
res_doc
.
_rev
=
doc
.
_rev
;
...
@@ -665,6 +672,7 @@
...
@@ -665,6 +672,7 @@
err
.
message
=
"
Cannot get attachment
"
;
err
.
message
=
"
Cannot get attachment
"
;
return
onEnd
(
err
,
undefined
);
return
onEnd
(
err
,
undefined
);
}
}
res_list
=
res_list
.
data
;
attachment_list
=
res_list
||
[];
attachment_list
=
res_list
||
[];
if
(
specific_parameter
.
getAttachment
)
{
if
(
specific_parameter
.
getAttachment
)
{
// getting specific attachment
// getting specific attachment
...
@@ -745,7 +753,6 @@
...
@@ -745,7 +753,6 @@
return
onEnd
(
err
,
undefined
);
return
onEnd
(
err
,
undefined
);
}
}
response_object
=
{
response_object
=
{
"
ok
"
:
true
,
"
id
"
:
doc
.
_id
,
"
id
"
:
doc
.
_id
,
"
rev
"
:
doc
.
_rev
"
rev
"
:
doc
.
_rev
};
};
...
@@ -784,7 +791,7 @@
...
@@ -784,7 +791,7 @@
if
(
err
)
{
if
(
err
)
{
return
command
.
error
(
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