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
Douglas
jio
Commits
06d0b3f4
Commit
06d0b3f4
authored
Jan 23, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indexStorage: PUT new API and qunit
parent
f89b3df8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
12 deletions
+125
-12
src/jio.storage/indexstorage.js
src/jio.storage/indexstorage.js
+11
-1
test/jiotests.js
test/jiotests.js
+114
-11
No files found.
src/jio.storage/indexstorage.js
View file @
06d0b3f4
...
@@ -214,6 +214,8 @@ jIO.addStorageType('indexed', function (spec, my) {
...
@@ -214,6 +214,8 @@ jIO.addStorageType('indexed', function (spec, my) {
priv
.
index_suffix
,
priv
.
index_suffix
,
option
,
option
,
function
(
response
)
{
function
(
response
)
{
console
.
log
(
"
index file found, we post(put)
"
);
console
.
log
(
indices
);
indices
=
response
;
indices
=
response
;
f
.
postDocument
(
"
put
"
);
f
.
postDocument
(
"
put
"
);
},
},
...
@@ -234,7 +236,7 @@ jIO.addStorageType('indexed', function (spec, my) {
...
@@ -234,7 +236,7 @@ jIO.addStorageType('indexed', function (spec, my) {
f
.
postDocument
=
function
(
index_update_method
)
{
f
.
postDocument
=
function
(
index_update_method
)
{
// if the index file already has an entry with this id,
// if the index file already has an entry with this id,
// the document already exists
// the document already exists
if
(
priv
.
docidInIndex
(
indices
,
doc
))
{
if
(
priv
.
docidInIndex
(
indices
,
doc
)
&&
index_update_method
===
'
POST
'
)
{
// POST the document already exists
// POST the document already exists
that
.
error
({
that
.
error
({
"
status
"
:
409
,
"
status
"
:
409
,
...
@@ -292,6 +294,14 @@ jIO.addStorageType('indexed', function (spec, my) {
...
@@ -292,6 +294,14 @@ jIO.addStorageType('indexed', function (spec, my) {
f
.
getIndices
();
f
.
getIndices
();
};
};
/**
* Update the document metadata and update the index
* @method put
* @param {object} command The JIO command
*/
that
.
put
=
function
(
command
)
{
that
.
post
(
command
);
};
/*
/*
/**
/**
* @method formatToFileObject
* @method formatToFileObject
...
...
test/jiotests.js
View file @
06d0b3f4
...
@@ -2628,13 +2628,10 @@ test ("Post", function () {
...
@@ -2628,13 +2628,10 @@ test ("Post", function () {
o
.
jio
=
JIO
.
newJio
({
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
indexed
"
,
"
type
"
:
"
indexed
"
,
"
indices
"
:
[{
"
indices
"
:
[
"
name
"
:
"
indexA
"
,
{
"
name
"
:
"
indexA
"
,
"
fields
"
:[
"
findMeA
"
]},
"
fields
"
:[
"
findMeA
"
]
{
"
name
"
:
"
indexAB
"
,
"
fields
"
:[
"
findMeA
"
,
"
findMeB
"
]}
},{
],
"
name
"
:
"
indexAB
"
,
"
fields
"
:[
"
findMeA
"
,
"
findMeB
"
]
}],
"
sub_storage
"
:
{
"
sub_storage
"
:
{
"
type
"
:
"
local
"
,
"
type
"
:
"
local
"
,
"
username
"
:
"
ipost
"
,
"
username
"
:
"
ipost
"
,
...
@@ -2661,13 +2658,20 @@ test ("Post", function () {
...
@@ -2661,13 +2658,20 @@ test ("Post", function () {
"
indexA
"
:
{
"
keyword_abc
"
:[
"
some_id
"
]}
"
indexA
"
:
{
"
keyword_abc
"
:[
"
some_id
"
]}
};
};
deepEqual
(
deepEqual
(
o
.
jio
.
get
(
"
ipost_indices.json
"
),
o
.
jio
.
get
(
"
ipost_indices.json
"
),
o
.
indexPost
,
"
Check index file
"
o
.
indexPost
,
"
Check index file
"
);
);
// post with escapable characters
o
.
doc
=
{
"
_id
"
:
"
other_id
"
,
"
title
"
:
"
myPost2
"
,
"
findMeA
"
:
"
keyword_*§$%&/()=?
"
,
"
findMeB
"
:
"
keyword_|ð@ł¶đæðſæðæſ³
"
};
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
other_id
"
},
"
Post with escapable characters
"
);
o
.
jio
.
post
(
o
.
doc
,
o
.
f
);
o
.
tick
(
o
);
// post and document already exists
// post and document already exists
o
.
doc
=
{
"
_id
"
:
"
some_id
"
,
"
title
"
:
"
myPost
2
"
,
o
.
doc
=
{
"
_id
"
:
"
some_id
"
,
"
title
"
:
"
myPost
3
"
,
"
findMeA
"
:
"
keyword_ghi
"
,
"
findMeB
"
:
"
keyword_jkl
"
"
findMeA
"
:
"
keyword_ghi
"
,
"
findMeB
"
:
"
keyword_jkl
"
}
}
o
.
spy
(
o
,
"
status
"
,
409
,
"
Post and document already exists
"
);
o
.
spy
(
o
,
"
status
"
,
409
,
"
Post and document already exists
"
);
...
@@ -2676,6 +2680,105 @@ test ("Post", function () {
...
@@ -2676,6 +2680,105 @@ test ("Post", function () {
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
test
(
"
Put
"
,
function
(){
var
o
=
generateTools
(
this
);
o
.
jio
=
JIO
.
newJio
({
"
type
"
:
"
indexed
"
,
"
indices
"
:
[
{
"
name
"
:
"
indexA
"
,
"
fields
"
:[
"
author
"
]},
{
"
name
"
:
"
indexAB
"
,
"
fields
"
:[
"
author
"
,
"
findMeC
"
]}
],
"
sub_storage
"
:
{
"
type
"
:
"
local
"
,
"
username
"
:
"
iput
"
,
"
application_name
"
:
"
iput
"
}
});
// put without id
// error 20 -> document id required
o
.
spy
(
o
,
"
status
"
,
20
,
"
Put without id
"
);
o
.
jio
.
put
({},
o
.
f
);
o
.
tick
(
o
);
// put non empty document
o
.
doc
=
{
"
_id
"
:
"
put1
"
,
"
title
"
:
"
myPut1
"
,
"
author
"
:
"
John Doe
"
};
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
put1
"
},
"
Put-create document
"
);
o
.
jio
.
put
(
o
.
doc
,
o
.
f
);
o
.
tick
(
o
);
// check index file
o
.
indexPut
=
{
"
indexA
"
:
{
"
John Doe
"
:
[
"
put1
"
]},
"
indexAB
"
:
{
"
John Doe
"
:
[
"
put1
"
]},
"
_id
"
:
"
iput_indices.json
"
};
deepEqual
(
o
.
jio
.
get
(
"
iput_indices.json
"
),
o
.
indexPut
,
"
Check index file
"
,
o
.
index
,
"
Check index file
"
);
// modify a document - modify keyword on index!
o
.
doc
=
{
"
_id
"
:
"
put1
"
,
"
title
"
:
"
myPuttter1
"
,
"
author
"
:
"
Jane Doe
"
};
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
put1
"
},
"
Modify document, update index file
"
);
o
.
jio
.
put
(
o
.
doc
,
o
.
f
);
o
.
tick
(
o
);
// check index file
o
.
index
=
{
"
indexA
"
:
{
"
Jane Doe
"
:
[
"
put1
"
]},
"
indexAB
"
:
{
"
Jane Doe
"
:
[
"
put1
"
]},
"
_id
"
:
"
iput_indices.json
"
};
deepEqual
(
o
.
jio
.
get
(
"
iput_indices.json
"
),
o
.
indexPut
,
"
Check index file
"
,
o
.
index
,
"
Check index file
"
);
// add new document with same keyword!
o
.
doc
=
{
"
_id
"
:
"
new_doc
"
,
"
title
"
:
"
myPut2
"
,
"
author
"
:
"
Jane Doe
"
};
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
new_doc
"
},
"
Add new document with same keyword
"
);
o
.
jio
.
put
(
o
.
doc
,
o
.
f
);
o
.
tick
(
o
);
// check index file
o
.
index
=
{
"
indexA
"
:
{
"
Jane Doe
"
:
[
"
put1
"
,
"
new_doc
"
]
},
"
indexAB
"
:
{
"
Jane Doe
"
:
[
"
put1
"
,
"
new_doc
"
]},
"
_id
"
:
"
iput_indices.json
"
};
deepEqual
(
o
.
jio
.
get
(
"
iput_indices.json
"
),
o
.
indexPut
,
"
Check index file
"
,
o
.
index
,
"
Check index file
"
);
// remove a keyword from an existing document
o
.
doc
=
{
"
_id
"
:
"
new_doc
"
,
"
title
"
:
"
myPut2
"
};
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
new_doc
"
},
"
Remove keyword from existing document
"
);
o
.
jio
.
put
(
o
.
doc
,
o
.
f
);
o
.
tick
(
o
);
// check index file
o
.
index
=
{
"
indexA
"
:
{
"
Jane Doe
"
:
[
"
put1
"
]
},
"
indexAB
"
:
{
"
Jane Doe
"
:
[
"
put1
"
]},
"
_id
"
:
"
iput_indices.json
"
};
deepEqual
(
o
.
jio
.
get
(
"
iput_indices.json
"
),
o
.
indexPut
,
"
Check index file
"
,
o
.
index
,
"
Check index file
"
);
o
.
jio
.
stop
();
});
/*
/*
test ('Document load', function () {
test ('Document load', function () {
var o = {}; o.clock = this.sandbox.useFakeTimers();
var o = {}; o.clock = this.sandbox.useFakeTimers();
...
...
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