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
Aurélien Vermylen
jio
Commits
17965461
Commit
17965461
authored
Apr 16, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
query storage can handle some options for sub storage
parent
b874d994
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
9 deletions
+40
-9
src/jio.storage/querystorage.js
src/jio.storage/querystorage.js
+40
-9
No files found.
src/jio.storage/querystorage.js
View file @
17965461
...
...
@@ -139,18 +139,49 @@
*/
QueryStorage
.
prototype
.
allDocs
=
function
(
command
,
param
,
options
)
{
var
that
=
this
,
substorage
=
command
.
storage
(
this
.
_sub_storage
),
// we need the full documents in order to perform the query, will
// remove them later if they were not required.
include_docs
=
(
options
.
include_docs
||
options
.
query
)
?
true
:
false
;
supported_options
=
{
"
limit
"
:
true
,
"
query
"
:
true
,
"
select_list
"
:
true
,
"
sort_on
"
:
true
// include_docs too, but it should be managed by sub storage
},
cloned_options
=
JSON
.
parse
(
JSON
.
stringify
(
options
)),
substorage
=
command
.
storage
(
this
.
_sub_storage
);
substorage
.
allDocs
({
"
include_docs
"
:
include_docs
substorage
.
allDocs
(
cloned_options
).
then
(
null
,
function
(
reason
)
{
if
(
reason
.
error
!==
"
UnsupportedOptionError
"
||
!
Array
.
isArray
(
reason
[
"
arguments
"
])
||
reason
[
"
arguments
"
].
length
===
0
)
{
throw
reason
;
}
var
offset
=
0
;
reason
[
"
arguments
"
].
slice
().
forEach
(
function
(
unsupported_option
,
i
)
{
if
(
supported_options
[
unsupported_option
])
{
reason
[
"
arguments
"
].
splice
(
i
+
offset
,
1
);
offset
-=
1
;
if
({
"
query
"
:
1
,
"
sort_on
"
:
1
}[
unsupported_option
])
{
cloned_options
.
include_docs
=
true
;
delete
cloned_options
.
limit
;
}
else
if
({
"
select_list
"
:
1
}[
unsupported_option
])
{
cloned_options
.
include_docs
=
true
;
}
}
delete
cloned_options
[
unsupported_option
];
});
if
(
reason
[
"
arguments
"
].
length
>
0
)
{
throw
{
"
status
"
:
501
,
"
error
"
:
"
UnsupportedOptionError
"
,
"
reason
"
:
"
unspported option
"
,
"
arguments
"
:
reason
[
"
arguments
"
]
};
}
return
substorage
.
allDocs
(
cloned_options
);
}).
then
(
function
(
response
)
{
var
data_rows
=
response
.
data
.
rows
,
docs
=
{},
row
,
i
,
l
;
if
(
!
include_docs
)
{
if
(
!
cloned_options
.
include_docs
)
{
return
response
;
}
...
...
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