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
preetwinder
jio
Commits
f8efbe05
Commit
f8efbe05
authored
Mar 27, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to create document in union.put
parent
1b3203be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
src/jio.storage/unionstorage.js
src/jio.storage/unionstorage.js
+8
-0
test/jio.storage/unionstorage.tests.js
test/jio.storage/unionstorage.tests.js
+39
-0
No files found.
src/jio.storage/unionstorage.js
View file @
f8efbe05
...
...
@@ -102,6 +102,14 @@
var
arg
=
arguments
,
context
=
this
;
return
this
.
_getWithStorageIndex
({
"
_id
"
:
arg
[
0
].
_id
})
.
push
(
undefined
,
function
(
error
)
{
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
404
))
{
// Document does not exist, create in first substorage
return
[
0
];
}
throw
error
;
})
.
push
(
function
(
result
)
{
// Storage found, modify in it directly
var
sub_storage
=
context
.
_storage_list
[
result
[
0
]];
...
...
test/jio.storage/unionstorage.tests.js
View file @
f8efbe05
...
...
@@ -395,6 +395,45 @@
});
});
test
(
"
put create on first storage
"
,
function
()
{
stop
();
expect
(
4
);
function
StoragePut404
()
{
return
this
;
}
function
generatePut404Error
(
param
)
{
equal
(
param
.
_id
,
"
bar
"
,
"
get Put404 called
"
);
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
);
}
StoragePut404
.
prototype
.
get
=
generatePut404Error
;
StoragePut404
.
prototype
.
put
=
function
(
param
)
{
deepEqual
(
param
,
{
"
_id
"
:
"
bar
"
,
"
title
"
:
"
foo
"
},
"
put 404 called
"
);
return
param
.
_id
;
};
jIO
.
addStorage
(
'
unionstorageput404
'
,
StoragePut404
);
var
jio
=
jIO
.
createJIO
({
type
:
"
union
"
,
storage_list
:
[{
type
:
"
unionstorageput404
"
},
{
type
:
"
unionstorage404
"
}]
});
jio
.
put
({
"
_id
"
:
"
bar
"
,
"
title
"
:
"
foo
"
})
.
then
(
function
(
result
)
{
equal
(
result
,
"
bar
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// unionStorage.remove
/////////////////////////////////////////////////////////////////
...
...
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