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
Vincent Bechu
jio
Commits
de376e14
Commit
de376e14
authored
Sep 12, 2017
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[querystorage] Handle capacity schema.
parent
22b3e4fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
5 deletions
+108
-5
src/jio.storage/querystorage.js
src/jio.storage/querystorage.js
+6
-2
test/jio.storage/querystorage.tests.js
test/jio.storage/querystorage.tests.js
+102
-3
No files found.
src/jio.storage/querystorage.js
View file @
de376e14
...
...
@@ -47,7 +47,8 @@
var
this_storage_capacity_list
=
[
"
limit
"
,
"
sort
"
,
"
select
"
,
"
query
"
];
"
query
"
,
"
schema
"
];
if
(
this_storage_capacity_list
.
indexOf
(
name
)
!==
-
1
)
{
return
true
;
...
...
@@ -75,11 +76,14 @@
((
options
.
select_list
===
undefined
)
||
(
substorage
.
hasCapacity
(
"
select
"
)))
&&
((
options
.
limit
===
undefined
)
||
(
substorage
.
hasCapacity
(
"
limit
"
))))
{
(
substorage
.
hasCapacity
(
"
limit
"
)))
&&
((
options
.
schema
===
undefined
)
||
(
substorage
.
hasCapacity
(
"
schema
"
))))
{
sub_options
.
query
=
options
.
query
;
sub_options
.
sort_on
=
options
.
sort_on
;
sub_options
.
select_list
=
options
.
select_list
;
sub_options
.
limit
=
options
.
limit
;
sub_options
.
schema
=
options
.
schema
;
}
}
catch
(
error
)
{
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
...
...
test/jio.storage/querystorage.tests.js
View file @
de376e14
...
...
@@ -400,7 +400,8 @@
(
capacity
===
"
sort
"
)
||
(
capacity
===
"
select
"
)
||
(
capacity
===
"
limit
"
)
||
(
capacity
===
"
query
"
))
{
(
capacity
===
"
query
"
)
||
(
capacity
===
"
schema
"
))
{
return
true
;
}
throw
new
Error
(
"
Unexpected
"
+
capacity
+
"
capacity check
"
);
...
...
@@ -410,7 +411,8 @@
sort_on
:
[[
"
title
"
,
"
ascending
"
]],
limit
:
[
5
],
select_list
:
[
"
title
"
,
"
id
"
],
query
:
'
title: "two"
'
query
:
'
title: "two"
'
,
schema
:
{
'
title
'
:
'
string
'
}
},
"
buildQuery called
"
);
return
"
taboulet
"
;
...
...
@@ -429,7 +431,8 @@
sort_on
:
[[
"
title
"
,
"
ascending
"
]],
limit
:
[
5
],
select_list
:
[
"
title
"
,
"
id
"
],
query
:
'
title: "two"
'
query
:
'
title: "two"
'
,
schema
:
{
'
title
'
:
'
string
'
}
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
...
...
@@ -823,6 +826,102 @@
});
});
test
(
"
manual query used if substorage does not handle schema
"
,
function
()
{
stop
();
expect
(
4
);
function
StorageSchemaCapacity
()
{
return
this
;
}
StorageSchemaCapacity
.
prototype
.
get
=
function
(
id
)
{
var
doc
=
{
title
:
id
,
id
:
"
ID
"
+
id
,
"
another
"
:
"
property
"
};
if
(
id
===
"
foo
"
)
{
equal
(
id
,
"
foo
"
,
"
Get foo
"
);
doc
.
modification_date
=
"
Fri, 08 Sep 2017 07:46:27 +0000
"
;
}
else
{
equal
(
id
,
"
bar
"
,
"
Get bar
"
);
doc
.
modification_date
=
"
Thu, 07 Sep 2017 18:59:23 +0000
"
;
}
return
doc
;
};
StorageSchemaCapacity
.
prototype
.
hasCapacity
=
function
(
capacity
)
{
if
((
capacity
===
"
list
"
)
||
(
capacity
===
"
select
"
)
||
(
capacity
===
"
limit
"
))
{
return
true
;
}
return
false
;
};
StorageSchemaCapacity
.
prototype
.
buildQuery
=
function
(
options
)
{
deepEqual
(
options
,
{},
"
No query parameter
"
);
var
result2
=
[{
id
:
"
foo
"
,
value
:
{}
},
{
id
:
"
bar
"
,
value
:
{}
}];
return
result2
;
};
jIO
.
addStorage
(
'
querystoragenoschemacapacity
'
,
StorageSchemaCapacity
);
var
jio
=
jIO
.
createJIO
({
type
:
"
query
"
,
sub_storage
:
{
type
:
"
querystoragenoschemacapacity
"
}
});
jio
.
allDocs
({
sort_on
:
[[
"
modification_date
"
,
"
descending
"
]],
limit
:
[
0
,
5
],
select_list
:
[
'
modification_date
'
],
schema
:
{
"
modification_date
"
:
{
"
type
"
:
"
string
"
,
"
format
"
:
"
date-time
"
}
}
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
data
:
{
rows
:
[
{
id
:
"
foo
"
,
doc
:
{},
value
:
{
modification_date
:
"
Fri, 08 Sep 2017 07:46:27 +0000
"
}
},
{
id
:
"
bar
"
,
doc
:
{},
value
:
{
modification_date
:
"
Thu, 07 Sep 2017 18:59:23 +0000
"
}
}
],
total_rows
:
2
}
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// queryStorage.repair
/////////////////////////////////////////////////////////////////
...
...
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