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
Ivan Tyagov
jio
Commits
62947ca8
Commit
62947ca8
authored
Oct 31, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indexstorage.js can now add metadata to databases
parent
6246d78b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
6 deletions
+41
-6
src/jio.storage/indexstorage.js
src/jio.storage/indexstorage.js
+9
-4
test/jio.storage/indexstorage.tests.js
test/jio.storage/indexstorage.tests.js
+32
-2
No files found.
src/jio.storage/indexstorage.js
View file @
62947ca8
...
...
@@ -509,13 +509,18 @@
});
}
function
createDatabaseAndPutAttachmentIfPossible
(
err
)
{
var
metadata
;
if
(
err
.
status
===
404
)
{
metadata
=
{
"
_id
"
:
index
.
id
};
if
(
typeof
index
.
metadata
===
'
object
'
&&
// adding metadata
index
.
metadata
!==
null
&&
!
Array
.
isArray
(
index
.
metadata
))
{
metadata
=
jIO
.
util
.
dictUpdate
(
metadata
,
index
.
metadata
);
}
return
command
.
storage
(
index
.
sub_storage
||
that
.
_sub_storage
).
post
({
"
_id
"
:
index
.
id
// XXX add metadata to document if necessary
}).
then
(
putAttachment
,
null
,
function
()
{
).
post
(
metadata
).
then
(
putAttachment
,
null
,
function
()
{
throw
null
;
// stop post progress propagation
});
}
...
...
test/jio.storage/indexstorage.tests.js
View file @
62947ca8
...
...
@@ -69,7 +69,7 @@
module
(
"
IndexStorage
"
);
test
(
"
Scenario
"
,
3
8
,
function
()
{
test
(
"
Scenario
"
,
3
9
,
function
()
{
var
LOCAL_STORAGE_SPEC
=
local_storage
.
createDescription
(
'
indexstorage tests
'
,
...
...
@@ -78,7 +78,9 @@
),
INDEX_STORAGE_SPEC
=
{
"
type
"
:
"
indexed
"
,
"
indices
"
:
[
{
"
id
"
:
"
A
"
,
"
index
"
:
[
"
contributor
"
]},
{
"
id
"
:
"
A
"
,
"
index
"
:
[
"
contributor
"
],
"
metadata
"
:
{
"
title
"
:
"
Database - A
"
}},
{
"
id
"
:
"
B
"
,
"
index
"
:
[
"
author
"
]},
{
"
id
"
:
"
C
"
,
"
index
"
:
[
"
title
"
]},
{
"
id
"
:
"
D
"
,
"
index
"
:
[
"
title
"
,
"
year
"
]}
...
...
@@ -378,6 +380,32 @@
},
"
List 8 documents from local (4 document + 4 databases)
"
);
}
function
getDatabaseMetadata
()
{
return
jio_local
.
get
({
"
_id
"
:
"
A
"
});
}
function
getDatabaseMetadataTest
(
answer
)
{
deepEqual
(
answer
,
{
"
data
"
:
{
"
_attachments
"
:
{
"
body
"
:
{
"
content_type
"
:
"
application/json
"
,
"
digest
"
:
"
sha256-365910ba219365b68e3431f9762eef21f
"
+
"
77cd390dbcc55d827d42555c66340a6
"
,
"
length
"
:
105
}
},
"
_id
"
:
"
A
"
,
"
title
"
:
"
Database - A
"
},
"
id
"
:
"
A
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check one index database metadata
"
);
}
// function removeCreatedDocuments() {
// return success(RSVP.all([
// jio_index.remove({"_id": shared.created_document_id}),
...
...
@@ -914,6 +942,8 @@
then
(
listDocumentsFromNothingTest
).
// allD 200 8 documents from local
then
(
listDocumentsFromLocal
).
then
(
listDocumentsFromLocalTest
).
// get 200 database to check metadatas from local
then
(
getDatabaseMetadata
).
then
(
getDatabaseMetadataTest
).
// remove a b ce dee 204
then
(
removeCreatedDocuments
).
then
(
removeCreatedDocumentsTest
).
// allD 200 empty indexes
...
...
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