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
Alexandra Rogova
jio
Commits
a97df9e9
Commit
a97df9e9
authored
Jul 17, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gidstorage.js get, alldocs method done + tests
parent
7f5f4e44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
8 deletions
+113
-8
src/jio.storage/gidstorage.js
src/jio.storage/gidstorage.js
+40
-5
test/jiotests.js
test/jiotests.js
+73
-3
No files found.
src/jio.storage/gidstorage.js
View file @
a97df9e9
...
...
@@ -350,14 +350,15 @@
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
,
"
error
"
:
"
conflict
"
,
"
message
"
:
"
Cannot
pos
t document
"
,
"
message
"
:
"
Cannot
ge
t document
"
,
"
reason
"
:
"
metadata should respect constraints
"
});
}
complex_query
=
gidToComplexQuery
(
gid_object
);
that
.
addJob
(
'
allDocs
'
,
priv
.
sub_storage
,
{},
{
"
query
"
:
complex_query
,
"
wildcard_character
"
:
null
"
wildcard_character
"
:
null
,
"
include_docs
"
:
true
},
function
(
response
)
{
if
(
response
.
total_rows
===
0
)
{
return
that
.
error
({
...
...
@@ -368,10 +369,44 @@
"
reason
"
:
"
missing
"
});
}
// XXX
return
that
.
success
(
response
.
rows
[
0
].
doc
);
},
function
(
err
)
{
err
.
message
=
"
Cannot post document
"
;
that
.
error
(
err
);
err
.
message
=
"
Cannot get document
"
;
return
that
.
error
(
err
);
});
});
};
that
.
allDocs
=
function
(
command
)
{
setTimeout
(
function
()
{
var
options
=
command
.
cloneOption
(),
include_docs
;
include_docs
=
options
.
include_docs
;
options
.
include_docs
=
true
;
that
.
addJob
(
'
allDocs
'
,
priv
.
sub_storage
,
{
},
options
,
function
(
response
)
{
var
result
=
[],
doc_gids
=
{},
i
,
row
,
gid
;
console
.
log
(
JSON
.
parse
(
JSON
.
stringify
(
response
)));
while
((
row
=
response
.
rows
.
shift
())
!==
undefined
)
{
if
((
gid
=
gidFormat
(
row
.
doc
,
priv
.
constraints
))
!==
undefined
)
{
if
(
!
doc_gids
[
gid
])
{
doc_gids
[
gid
]
=
true
;
row
.
id
=
gid
;
delete
row
.
key
;
result
[
result
.
length
]
=
row
;
if
(
include_docs
===
true
)
{
row
.
doc
.
_id
=
gid
;
}
else
{
delete
row
.
doc
;
}
}
}
}
doc_gids
=
undefined
;
// free memory
row
=
undefined
;
that
.
success
({
"
total_rows
"
:
result
.
length
,
"
rows
"
:
result
});
},
function
(
err
)
{
err
.
message
=
"
Cannot get all documents
"
;
return
that
.
error
(
err
);
});
});
};
...
...
test/jiotests.js
View file @
a97df9e9
...
...
@@ -8038,17 +8038,87 @@ test("Get", function () {
});
o
.
local_jio
.
put
({
"
_id
"
:
"
blue
"
,
"
identifier
"
:
"
a
"
});
o
.
local_jio
.
put
({
"
_id
"
:
"
green
"
,
"
identifier
"
:
[
"
ac
"
,
"
b
"
]});
o
.
local_jio
.
put
({
"
_id
"
:
"
red
"
,
"
identifier
"
:
[
"
ac
"
,
"
b
"
]});
o
.
clock
.
tick
(
2000
);
o
.
local_jio
.
stop
();
o
.
spy
(
o
,
'
status
'
,
404
,
'
Get inexistent document
'
);
o
.
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
]}
"
},
o
.
f
);
o
.
tick
(
o
);
o
.
spy
(
o
,
'
value
'
,
{
"
_id
"
:
"
red
"
,
"
identifier
"
:
[
"
ac
"
,
"
b
"
]},
'
Get document
'
);
o
.
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
},
o
.
f
);
o
.
tick
(
o
);
o
.
spy
(
o
,
'
value
'
,
{
"
_id
"
:
"
blue
"
,
"
identifier
"
:
"
a
"
},
'
Get document
'
);
o
.
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
},
o
.
f
);
o
.
jio
.
stop
();
});
test
(
"
AllDocs
"
,
function
()
{
var
o
=
generateTools
(
this
);
o
.
localstorage_spec
=
{
"
type
"
:
"
local
"
,
"
username
"
:
"
one
"
,
"
application_name
"
:
"
gid storage allDocs test
"
};
o
.
local_jio
=
JIO
.
newJio
(
o
.
localstorage_spec
);
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
gid
"
,
"
sub_storage
"
:
o
.
localstorage_spec
,
"
constraints
"
:
{
"
default
"
:
{
"
identifier
"
:
"
list
"
}
}
});
o
.
local_jio
.
put
({
"
_id
"
:
"
green
"
,
"
identifier
"
:
[
"
a
"
]})
o
.
local_jio
.
put
({
"
_id
"
:
"
red
"
,
"
identifier
"
:
[
"
a
"
,
"
b
"
]})
o
.
local_jio
.
put
({
"
_id
"
:
"
yellow
"
,
"
identifier
"
:
[
"
c
"
,
"
d
"
]})
o
.
local_jio
.
put
({
"
_id
"
:
"
purple
"
,
"
identifier
"
:
[
"
p
"
,
"
d
"
]})
o
.
clock
.
tick
(
3000
);
console
.
log
(
JSON
.
parse
(
JSON
.
stringify
(
localStorage
)));
o
.
local_jio
.
stop
();
o
.
spy
(
o
,
'
value
'
,
{
"
rows
"
:
[{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
,
"
value
"
:
{}
},
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
,
\"
b
\"
]}
"
,
"
value
"
:
{}
},
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
,
\"
d
\"
]}
"
,
"
value
"
:
{}
},
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
p
\"
,
\"
d
\"
]}
"
,
"
value
"
:
{}
}],
"
total_rows
"
:
4
},
'
Get all docs
'
);
o
.
jio
.
allDocs
({
"
sort_on
"
:
[[
"
identifier
"
,
"
ascending
"
]]
},
o
.
f
);
o
.
tick
(
o
);
o
.
spy
(
o
,
'
value
'
,
{
"
rows
"
:
[{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
,
\"
b
\"
]}
"
,
"
value
"
:
{}
}],
"
total_rows
"
:
1
},
'
Get all docs
'
);
o
.
jio
.
allDocs
({
"
query
"
:
'
identifier: "a"
'
,
"
select
"
:
[
"
identifier
"
],
"
limit
"
:
[
1
,
1
],
"
sort_on
"
:
[[
"
identifier
"
,
"
ascending
"
]]
},
o
.
f
);
o
.
tick
(
o
);
o
.
jio
.
stop
();
...
...
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